Top Description Inners Fields Constructors Methods
org.jruby

public Class RubyEnumerator

extends RubyObject
implements Iterator<Object>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Annotations
@JRubyModule
name:Enumerator
include:Enumerable
Imports
org.jruby.anno.JRubyMethod, .JRubyModule, org.jruby.exceptions.StopIteration, org.jruby.runtime.Arity, .Block, .CallBlock, .JavaSites, .Signature, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.ArraySupport, .ByteList, java.util.Spliterator, java.util.stream.Stream

Implementation of Ruby's Enumerator module.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
RubyEnumerator.FeedValue

Internal Enumerator::FeedValue class to be shared between enumerator and its next-er Fiber.

public static interface
RubyEnumerator.SizeFn<
the enumerated object's type
T extends IRubyObject
>

"Function" type for java-created enumerators with size.

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
private RubyEnumerator.FeedValue
public static final String
public static final String
public static final String
private String
method

method to invoke for each operation

private IRubyObject[]
methodArgs

args to each method

private boolean
methodArgsHasKeywords

args contains a keywords argument

public static final String
private IRubyObject
object

target for each operation

private IRubyObject
size

A value or proc to provide the size of the Enumerator contents

private RubyEnumerator.SizeFn<T extends IRubyObject>
sizeFn

Function object for lazily computing size (used for internally created enumerators)

Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
private
RubyEnumerator(Ruby runtime, RubyClass type)

private
RubyEnumerator(Ruby runtime, RubyClass type, IRubyObject object, RubySymbol method, IRubyObject[] args, IRubyObject size, RubyEnumerator.SizeFn<T extends IRubyObject> sizeFn, boolean keywords)

private
RubyEnumerator(Ruby runtime, RubyClass type, IRubyObject object, IRubyObject method, IRubyObject[] args)

Method Summary

Modifier and TypeMethod and Description
private IRubyObject
__each__(ThreadContext context, final Block block)

public static IRubyObject
__from(ThreadContext context, IRubyObject klass, IRubyObject[] args)

private static void
public static RubyClass
defineEnumerator(ThreadContext context, RubyClass Object, RubyModule Enumerable)

public IRubyObject
public IRubyObject
each(ThreadContext context, Block block)

Send current block and supplied args to method on target.

public IRubyObject
each(ThreadContext context, IRubyObject[] args, Block block)

public IRubyObject
each_cons(ThreadContext context, IRubyObject arg, final Block block)

public IRubyObject
each_entry(ThreadContext context, final Block block)

public IRubyObject
each_entry(ThreadContext context, final IRubyObject arg0, final Block block)

public IRubyObject
each_entry(ThreadContext context, final IRubyObject[] args, final Block block)

public IRubyObject
each_slice(ThreadContext context, IRubyObject arg, final Block block)

public IRubyObject
each_with_index(ThreadContext context, final Block block)

public IRubyObject
each_with_object(final ThreadContext context, IRubyObject arg, Block block)

public static IRubyObject
enumeratorize(Ruby runtime, IRubyObject object, String method)

public static IRubyObject
enumeratorize(Ruby runtime, IRubyObject object, String method, IRubyObject arg)

public static IRubyObject
enumeratorize(Ruby runtime, IRubyObject object, String method, IRubyObject... args)

public static IRubyObject
enumeratorize(Ruby runtime, RubyClass type, IRubyObject object, String method)

public static IRubyObject
enumeratorize(Ruby runtime, RubyClass type, IRubyObject object, String method, IRubyObject arg)

public static IRubyObject
enumeratorize(Ruby runtime, RubyClass type, IRubyObject object, String method, IRubyObject[] args)

public static <T extends IRubyObject> IRubyObject
enumeratorizeWithSize(ThreadContext context, final T object, String method, IRubyObject[] args, RubyEnumerator.SizeFn<T> sizeFn, boolean keywords)

public static <T extends IRubyObject> IRubyObject
enumeratorizeWithSize(ThreadContext context, final T object, String method, IRubyObject[] args, RubyEnumerator.SizeFn<T> sizeFn)

public static <T extends IRubyObject> IRubyObject
enumeratorizeWithSize(ThreadContext context, T object, String method, RubyEnumerator.SizeFn<T> sizeFn)

public static IRubyObject
public static <T extends IRubyObject> RubyEnumerator
enumWithSize(ThreadContext context, final T object, String method, IRubyObject[] args, RubyEnumerator.SizeFn<T> sizeFn)

Transform object into an Enumerator with the given size

public static <T extends IRubyObject> RubyEnumerator
enumWithSize(ThreadContext context, T object, String method, RubyEnumerator.SizeFn<T> sizeFn)

private IRubyObject
public synchronized boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public IRubyObject
public IRubyObject
initialize(ThreadContext context, Block block)

public IRubyObject
initialize(ThreadContext context, IRubyObject size, Block block)

private IRubyObject
initialize(Ruby runtime, IRubyObject object, IRubyObject method, IRubyObject[] methodArgs)

private IRubyObject
initialize(Ruby runtime, IRubyObject object, IRubyObject method, IRubyObject[] methodArgs, IRubyObject size, RubyEnumerator.SizeFn<T extends IRubyObject> sizeFn, boolean keywords)

public IRubyObject
initialize(ThreadContext context, IRubyObject[] args, Block block)
Deprecated

public IRubyObject
initialize(ThreadContext context, IRubyObject[] args)
Deprecated

private IRubyObject
public IRubyObject
inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

Returns a string containing a human-readable representation of obj.

private IRubyObject
inspect(ThreadContext context, boolean recurse)

public Object
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public static IRubyObject
produce(ThreadContext context, IRubyObject recv, IRubyObject[] args, final Block block)

MRI: enumerator_s_produce

public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

private static JavaSites.FiberSites
sites(ThreadContext context)

Hides org.jruby.RubyObject.sites.

Retrieve the call sites for this class.

public final IRubyObject
public long
size()

private static IRubyObject
size(ThreadContext context, RubyEnumerator recv, IRubyObject[] args)

A size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

public Spliterator<Object>
public Spliterator<Object>
spliterator(final int mod)

public Stream<Object>
public Stream<Object>
stream(final boolean parallel)

public IRubyObject
with_index(ThreadContext context, final Block block)

public IRubyObject
with_index(ThreadContext context, IRubyObject arg, final Block block)

private IRubyObject
with_index_common(ThreadContext context, final Block block, final String rubyMethodName, IRubyObject arg)

public IRubyObject
with_object(ThreadContext context, final IRubyObject arg, final Block block)

Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalequalsfinishObjectClassgetNativeClassIndexhashCodeinspectop_eqqputsspecificEvaltoRubyStringtoString