Class: Enumerable::Enumerator
- Includes:
- Enumerable
- Defined in:
- enumerator.c,
enumerator.c
Overview
A class which provides a method ‘each’ to be used as an Enumerable object.
Instance Method Summary collapse
-
#each { ... } ⇒ Object
Iterates the given block using the object and the method specified in the first place.
-
#Enumerable::Enumerator.new(obj, method = :each, *args) ⇒ Object
constructor
Creates a new Enumerable::Enumerator object, which is to be used as an Enumerable object using the given object’s given method with the given arguments.
Methods included from Enumerable
#each_cons, #each_slice, #enum_cons, #enum_slice, #enum_with_index
Constructor Details
#Enumerable::Enumerator.new(obj, method = :each, *args) ⇒ Object
Creates a new Enumerable::Enumerator object, which is to be used as an Enumerable object using the given object’s given method with the given arguments.
e.g.:
str = "xyz"
enum = Enumerable::Enumerator.new(str, :each_byte)
a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
218 219 220 |
# File 'enumerator.c', line 218 static VALUE enumerator_initialize(argc, argv, obj) int argc; |
Instance Method Details
#each { ... } ⇒ Object
Iterates the given block using the object and the method specified in the first place.
253 254 255 |
# File 'enumerator.c', line 253 static VALUE enumerator_each(obj) VALUE obj; |