Class: Enumerator::Generator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
enumerator.c

Instance Method Summary collapse

Methods included from Enumerable

#all?, #any?, #chunk, #collect, #collect_concat, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_entry, #each_slice, #each_with_index, #each_with_object, #entries, #find, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #include?, #inject, #map, #max, #max_by, #member?, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reduce, #reject, #reverse_each, #select, #slice_before, #sort, #sort_by, #take, #take_while, #to_a, #zip

Constructor Details

#initializeObject

:nodoc:



# File 'enumerator.c'

static VALUE
generator_initialize(int argc, VALUE *argv, VALUE obj)
{
VALUE proc;

if (argc == 0) {
rb_need_block();

proc = rb_block_proc();
}

Instance Method Details

#eachObject

:nodoc:



# File 'enumerator.c'

static VALUE
generator_each(VALUE obj)
{
    struct generator *ptr = generator_ptr(obj);
    VALUE yielder;

    yielder = yielder_new();

    return rb_proc_call(ptr->proc, rb_ary_new3(1, yielder));
}

#initialize_copyObject

:nodoc:



# File 'enumerator.c'

static VALUE
generator_init_copy(VALUE obj, VALUE orig)
{
struct generator *ptr0, *ptr1;

ptr0 = generator_ptr(orig);

TypedData_Get_Struct(obj, struct generator, &generator_data_type, ptr1);

if (!ptr1) {
rb_raise(rb_eArgError, "unallocated generator");
}