Class: Enumerator::Generator
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Instance Chain: 
          self,
           ::Enumerable | |
| Inherits: | Object | 
| Defined in: | enumerator.c | 
Overview
Generator
Class Method Summary
- .new(*args) constructor Internal use only
Instance Method Summary
::Enumerable - Included
| #all? | Passes each element of the collection to the given block. | 
| #any? | Passes each element of the collection to the given block. | 
| #chain | Returns an enumerator object generated from this enumerator and given enumerables. | 
| #chunk | Enumerates over the items, chunking them together based on the return value of the block. | 
| #chunk_while | Creates an enumerator for each chunked elements. | 
| #collect | Alias for Enumerable#map. | 
| #collect_concat | Alias for Enumerable#flat_map. | 
| #count | Returns the number of items in  | 
| #cycle | Calls block for each element of enum repeatedly n times or forever if none or  | 
| #detect | Alias for Enumerable#find. | 
| #drop | Drops first n elements from enum, and returns rest elements in an array. | 
| #drop_while | Drops elements up to, but not including, the first element for which the block returns  | 
| #each_cons | Iterates the given block for each array of consecutive <n> elements. | 
| #each_entry | Calls block once for each element in  | 
| #each_slice | Iterates the given block for each slice of <n> elements. | 
| #each_with_index | Calls block with two arguments, the item and its index, for each item in enum. | 
| #each_with_object | Iterates the given block for each element with an arbitrary object given, and returns the initially given object. | 
| #entries | Alias for Enumerable#to_a. | 
| #filter | Returns an array containing all elements of  | 
| #filter_map | Returns a new array containing the truthy results (everything except  | 
| #find | Passes each entry in enum to block. | 
| #find_all | Alias for Enumerable#filter. | 
| #find_index | Compares each entry in enum with value or passes to block. | 
| #first | Returns the first element, or the first  | 
| #flat_map | Returns a new array with the concatenated results of running block once for every element in enum. | 
| #grep | Returns an array of every element in enum for which  | 
| #grep_v | Inverted version of Enumerable#grep. | 
| #group_by | Groups the collection by result of the block. | 
| #include? | Alias for Enumerable#member?. | 
| #inject | Combines all elements of enum by applying a binary operation, specified by a block or a symbol that names a method or operator. | 
| #lazy | Returns an  | 
| #map | Returns a new array with the results of running block once for every element in enum. | 
| #max | Returns the object in enum with the maximum value. | 
| #max_by | Returns the object in enum that gives the maximum value from the given block. | 
| #member? | Returns  | 
| #min | Returns the object in enum with the minimum value. | 
| #min_by | Returns the object in enum that gives the minimum value from the given block. | 
| #minmax | Returns a two element array which contains the minimum and the maximum value in the enumerable. | 
| #minmax_by | Returns a two element array containing the objects in enum that correspond to the minimum and maximum values respectively from the given block. | 
| #none? | Passes each element of the collection to the given block. | 
| #one? | Passes each element of the collection to the given block. | 
| #partition | Returns two arrays, the first containing the elements of enum for which the block evaluates to true, the second containing the rest. | 
| #reduce | Alias for Enumerable#inject. | 
| #reject | Returns an array for all elements of  | 
| #reverse_each | Builds a temporary array and traverses that array in reverse order. | 
| #select | Alias for Enumerable#filter. | 
| #slice_after | Creates an enumerator for each chunked elements. | 
| #slice_before | Creates an enumerator for each chunked elements. | 
| #slice_when | Creates an enumerator for each chunked elements. | 
| #sort | Returns an array containing the items in enum sorted. | 
| #sort_by | Sorts enum using a set of keys generated by mapping the values in enum through the given block. | 
| #sum | Returns the sum of elements in an  | 
| #take | Returns first n elements from enum. | 
| #take_while | Passes elements to the block until the block returns  | 
| #tally | Tallies the collection, i.e., counts the occurrences of each element. | 
| #to_a | Returns an array containing the items in enum. | 
| #to_h | Returns the result of interpreting enum as a list of  | 
| #uniq | Returns a new array by removing duplicate values in  | 
| #zip | Takes one element from enum and merges corresponding elements from each args. | 
Constructor Details
.new(*args)
# File 'enumerator.c', line 1461
static VALUE
generator_initialize(int argc, VALUE *argv, VALUE obj)
{
    VALUE proc;
    if (argc == 0) {
	rb_need_block();
	proc = rb_block_proc();
    }
    else {
	rb_scan_args(argc, argv, "1", &proc);
	if (!rb_obj_is_proc(proc))
	    rb_raise(rb_eTypeError,
		     "wrong argument type %"PRIsVALUE" (expected Proc)",
		     rb_obj_class(proc));
	if (rb_block_given_p()) {
	    rb_warn("given block not used");
	}
    }
    return generator_init(obj, proc);
}