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? | Returns whether every element meets a given criterion. | 
| #any? | Returns whether any element meets a given criterion. | 
| #chain | Returns an enumerator object generated from this enumerator and given enumerables. | 
| #chunk | Each element in the returned enumerator is a 2-element array consisting of: | 
| #chunk_while | Creates an enumerator for each chunked elements. | 
| #collect | Alias for Enumerable#map. | 
| #collect_concat | Alias for Enumerable#flat_map. | 
| #compact | Returns an array of all non- | 
| #count | Returns the count of elements, based on an argument or block criterion, if given. | 
| #cycle | When called with positive integer argument  | 
| #detect | Alias for Enumerable#find. | 
| #drop | For positive integer  | 
| #drop_while | Calls the block with successive elements as long as the block returns a truthy value; returns an array of all elements after that point: | 
| #each_cons | Calls the block with each successive overlapped  | 
| #each_entry | Calls the given block with each element, converting multiple values from yield to an array; returns  | 
| #each_slice | Calls the block with each successive disjoint  | 
| #each_with_index | With a block given, calls the block with each element and its index; returns  | 
| #each_with_object | Calls the block once for each element, passing both the element and the given object: | 
| #entries | Alias for Enumerable#to_a. | 
| #filter | Returns an array containing elements selected by the block. | 
| #filter_map | Returns an array containing truthy elements returned by the block. | 
| #find | Returns the first element for which the block returns a truthy value. | 
| #find_all | Alias for Enumerable#filter. | 
| #find_index | Returns the index of the first element that meets a specified criterion, or  | 
| #first | Returns the first element or elements. | 
| #flat_map | Returns an array of flattened objects returned by the block. | 
| #grep | Returns an array of objects based elements of  | 
| #grep_v | Returns an array of objects based on elements of  | 
| #group_by | With a block given returns a hash: | 
| #include? | Alias for Enumerable#member?. | 
| #inject | Returns an object formed from operands via either: | 
| #lazy | Returns an  | 
| #map | Returns an array of objects returned by the block. | 
| #max | Returns the element with the maximum element according to a given criterion. | 
| #max_by | Returns the elements for which the block returns the maximum values. | 
| #member? | Returns whether for any element  | 
| #min | Returns the element with the minimum element according to a given criterion. | 
| #min_by | Returns the elements for which the block returns the minimum values. | 
| #minmax | Returns a 2-element array containing the minimum and maximum elements according to a given criterion. | 
| #minmax_by | Returns a 2-element array containing the elements for which the block returns minimum and maximum values: | 
| #none? | Returns whether no element meets a given criterion. | 
| #one? | Returns whether exactly one element meets a given criterion. | 
| #partition | With a block given, returns an array of two arrays: | 
| #reduce | Alias for Enumerable#inject. | 
| #reject | Returns an array of objects rejected by the block. | 
| #reverse_each | With a block given, calls the block with each element, but in reverse order; returns  | 
| #select | Alias for Enumerable#filter. | 
| #slice_after | Creates an enumerator for each chunked elements. | 
| #slice_before | With argument  | 
| #slice_when | Creates an enumerator for each chunked elements. | 
| #sort | Returns an array containing the sorted elements of  | 
| #sort_by | With a block given, returns an array of elements of  | 
| #sum | With no block given, returns the sum of  | 
| #take | For non-negative integer  | 
| #take_while | Calls the block with successive elements as long as the block returns a truthy value; returns an array of all elements up to that point: | 
| #tally | Returns a hash containing the counts of equal elements: | 
| #to_a | Returns an array containing the items in  | 
| #to_h | When  | 
| #uniq | With no block, returns a new array containing only unique elements; the array has no two elements  | 
| #zip | With no block given, returns a new array  | 
Constructor Details
.new(*args)
# File 'enumerator.c', line 1459
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);
}