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

#all?, #any?, #collect, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_slice, #each_with_index, #each_with_object, #entries, #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, #to_h, to_h, #uniq, #zip

Constructor Details

#initialize(&block) ⇒ Generator

Returns a new instance of Generator

Raises:


530
531
532
533
534
# File 'mrbgems/mruby-enumerator/mrblib/enumerator.rb', line 530

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


536
537
538
539
# File 'mrbgems/mruby-enumerator/mrblib/enumerator.rb', line 536

def each(*args, &block)
  args.unshift Yielder.new(&block)
  @proc.call(*args)
end