Class: Enumerator::Generator
- Inherits:
-
Object
- Object
- Enumerator::Generator
- Includes:
- Enumerable
- Defined in:
- mrbgems/mruby-enumerator/mrblib/enumerator.rb
Overview
just for internal
Constant Summary
Constants included from Enumerable
Instance Method Summary collapse
-
#each(*args, &block) ⇒ Object
-
#initialize(&block) ⇒ Generator
constructor
A new instance of Generator.
Methods included from Enumerable
__update_hash, #all?, #any?, #chain, #collect, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_slice, #each_with_index, #each_with_object, #entries, #filter_map, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #hash, #include?, #inject, #lazy, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reject, #reverse_each, #sort, #sort_by, #take, #take_while, #tally, #to_h, #uniq, #zip
Constructor Details
#initialize(&block) ⇒ Generator
Returns a new instance of Generator
529 530 531 532 533 |
# File 'mrbgems/mruby-enumerator/mrblib/enumerator.rb', line 529 def initialize(&block) raise TypeError, "wrong argument type #{self.class} (expected Proc)" unless block.kind_of? Proc @proc = block end |
Instance Method Details
#each(*args, &block) ⇒ Object
535 536 537 538 |
# File 'mrbgems/mruby-enumerator/mrblib/enumerator.rb', line 535 def each(*args, &block) args.unshift Yielder.new(&block) @proc.call(*args) end |