Class: Enumerator::Generator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
mrbgems/mruby-enumerator/mrblib/enumerator.rb

Overview

just for internal

Constant Summary

Constants included from Enumerable

Enumerable::NONE

Instance Method Summary collapse

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

Raises:



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