Class: Enumerator::Generator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
mruby/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, #sum, #take, #take_while, #tally, #to_h, #uniq, #zip

Constructor Details

#initialize(&block) ⇒ Generator

Returns a new instance of Generator.

Raises:



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

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



538
539
540
541
# File 'mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb', line 538

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