ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- PKJ ]jUwith_index-i.rinu[U:RDoc::AnyMethod[iI"with_index:ETI"Enumerator#with_index;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DIterates the given block for each element with an index, which ;TI"Kstarts from +offset+. If no block is given, returns a new Enumerator ;TI"4that includes the index, starting from +offset+;To:RDoc::Markup::BlankLineo:RDoc::Markup::List: @type: NOTE: @items[o:RDoc::Markup::ListItem: @label[I" +offset+;T; [o; ; [I"the starting index to use;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"Me.with_index(offset = 0) {|(*args), idx| ... } e.with_index(offset = 0) ;T0[I" (*args);T@FI"Enumerator;TcRDoc::NormalClass00PKJ ]AProducer/cdesc-Producer.rinu[U:RDoc::NormalClass[iI" Producer:ETI"Enumerator::Producer;TI" Object;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I" Producer;To:RDoc::Markup::BlankLine: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[;[[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[I"enumerator.c;TI"Enumerator;TcRDoc::NormalClassPKJ ]"UU inspect-i.rinu[U:RDoc::AnyMethod[iI" inspect:ETI"Enumerator#inspect;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"-Creates a printable version of e.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.inspect -> string ;T0[I"();T@FI"Enumerator;TcRDoc::NormalClass00PKJ ]{]ddChain/inspect-i.rinu[U:RDoc::AnyMethod[iI" inspect:ETI"Enumerator::Chain#inspect;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"9Returns a printable version of the enumerator chain.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"obj.inspect -> string ;T0[I"();T@FI" Chain;TcRDoc::NormalClass00PKJ ]ҋVVChain/new-c.rinu[U:RDoc::AnyMethod[iI"new:ETI"Enumerator::Chain::new;TT: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GGenerates a new enumerator object that iterates over the elements ;TI"-of given enumerable objects in sequence.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"-e = Enumerator::Chain.new(1..3, [4, 5]) ;TI" e.to_a #=> [1, 2, 3, 4, 5] ;TI"e.size #=> 5;T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"+Enumerator::Chain.new(*enums) -> enum ;T0[I" (*args);T@FI" Chain;TcRDoc::NormalClass00PKJ ]33Chain/size-i.rinu[U:RDoc::AnyMethod[iI" size:ETI"Enumerator::Chain#size;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"BReturns the total size of the enumerator chain calculated by ;TI"Isumming up the size of each enumerable in the chain. If any of the ;TI"Henumerables reports its size as nil or Float::INFINITY, that value ;TI"#is returned as the total size.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"-obj.size -> int, Float::INFINITY or nil ;T0[I"();T@FI" Chain;TcRDoc::NormalClass00PKJ ]HUChain/rewind-i.rinu[U:RDoc::AnyMethod[iI" rewind:ETI"Enumerator::Chain#rewind;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"IRewinds the enumerator chain by calling the "rewind" method on each ;TI"Fenumerable in reverse order. Each call is performed only if the ;TI"'enumerable responds to the method.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"obj.rewind -> obj ;T0[I"();T@FI" Chain;TcRDoc::NormalClass00PKJ ] Chain/each-i.rinu[U:RDoc::AnyMethod[iI" each:ETI"Enumerator::Chain#each;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"GIterates over the elements of the first enumerable by calling the ;TI"H"each" method on it with the given arguments, then proceeds to the ;TI"Hfollowing enumerables in sequence until all of the enumerables are ;TI"exhausted.;To:RDoc::Markup::BlankLineo; ; [I"1If no block is given, returns an enumerator.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"Hobj.each(*args) { |...| ... } -> obj obj.each(*args) -> enumerator ;T0[I" (*args);T@FI" Chain;TcRDoc::NormalClass00PKJ ]F]Chain/cdesc-Chain.rinu[U:RDoc::NormalClass[iI" Chain:ETI"Enumerator::Chain;TI"Enumerator;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"GEnumerator::Chain is a subclass of Enumerator, which represents a ;TI"Creates a new Enumerator object, which can be used as an ;TI"Enumerable.;To:RDoc::Markup::BlankLineo; ; [I"1Iteration is defined by the given block, in ;TI"Hwhich a "yielder" object, given as block parameter, can be used to ;TI"Nyield a value by calling the +yield+ method (aliased as <<):;T@o:RDoc::Markup::Verbatim; [I"!fib = Enumerator.new do |y| ;TI" a = b = 1 ;TI" loop do ;TI" y << a ;TI" a, b = b, a + b ;TI" end ;TI" end ;TI" ;TI":fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] ;T: @format0o; ; [I"MThe optional parameter can be used to specify how to calculate the size ;TI"Jin a lazy fashion (see Enumerator#size). It can either be a value or ;TI"a callable object.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"2Enumerator.new(size = nil) { |yielder| ... } ;T0[I" (*args);T@%FI"Enumerator;TcRDoc::NormalClass00PKJ ]ahh peek-i.rinu[U:RDoc::AnyMethod[iI" peek:ETI"Enumerator#peek;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"NReturns the next object in the enumerator, but doesn't move the internal ;TI"Mposition forward. If the position is already at the end, StopIteration ;TI"is raised.;To:RDoc::Markup::BlankLineo; ; [I"4See class-level notes about external iterators.;T@S:RDoc::Markup::Heading: leveli: textI" Example;T@o:RDoc::Markup::Verbatim; [I"a = [1,2,3] ;TI"e = a.to_enum ;TI"p e.next #=> 1 ;TI"p e.peek #=> 2 ;TI"p e.peek #=> 2 ;TI"p e.peek #=> 2 ;TI"p e.next #=> 2 ;TI"p e.next #=> 3 ;TI"%p e.peek #raises StopIteration;T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.peek -> object ;T0[I"();T@!FI"Enumerator;TcRDoc::NormalClass00PKJ ]D))each_with_object-i.rinu[U:RDoc::AnyMethod[iI"each_with_object:ETI" Enumerator#each_with_object;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"PIterates the given block for each element with an arbitrary object, +obj+, ;TI"and returns +obj+;To:RDoc::Markup::BlankLineo; ; [I"4If no block is given, returns a new Enumerator.;T@S:RDoc::Markup::Heading: leveli: textI" Example;T@o:RDoc::Markup::Verbatim; [I"&to_three = Enumerator.new do |y| ;TI" 3.times do |x| ;TI" y << x ;TI" end ;TI" end ;TI" ;TI"8to_three_with_string = to_three.with_object("foo") ;TI"-to_three_with_string.each do |x,string| ;TI" puts "#{string}: #{x}" ;TI" end ;TI" ;TI"# => foo: 0 ;TI"# => foo: 1 ;TI"# => foo: 2;T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.each_with_object(obj) {|(*args), obj| ... } e.each_with_object(obj) e.with_object(obj) {|(*args), obj| ... } e.with_object(obj) ;T0[[I"with_object;T@ I" (p1);T@%FI"Enumerator;TcRDoc::NormalClass00PKJ ]ߝ>next_values-i.rinu[U:RDoc::AnyMethod[iI"next_values:ETI"Enumerator#next_values;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"IReturns the next object as an array in the enumerator, and move the ;TI"Ginternal position forward. When the position reached at the end, ;TI"StopIteration is raised.;To:RDoc::Markup::BlankLineo; ; [I"4See class-level notes about external iterators.;T@o; ; [I"OThis method can be used to distinguish yield and yield ;TI"nil.;T@S:RDoc::Markup::Heading: leveli: textI" Example;T@o:RDoc::Markup::Verbatim; [ I"o = Object.new ;TI"def o.each ;TI" yield ;TI" yield 1 ;TI" yield 1, 2 ;TI" yield nil ;TI" yield [1, 2] ;TI" end ;TI"e = o.to_enum ;TI"p e.next_values ;TI"p e.next_values ;TI"p e.next_values ;TI"p e.next_values ;TI"p e.next_values ;TI"e = o.to_enum ;TI"p e.next ;TI"p e.next ;TI"p e.next ;TI"p e.next ;TI"p e.next ;TI" ;TI"/## yield args next_values next ;TI".# yield [] nil ;TI",# yield 1 [1] 1 ;TI"1# yield 1, 2 [1, 2] [1, 2] ;TI".# yield nil [nil] nil ;TI"0# yield [1, 2] [[1, 2]] [1, 2];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.next_values -> array ;T0[I"();T@7FI"Enumerator;TcRDoc::NormalClass00PKJ ]]WW size-i.rinu[U:RDoc::AnyMethod[iI" size:ETI"Enumerator#size;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"SReturns the size of the enumerator, or +nil+ if it can't be calculated lazily.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"5(1..100).to_a.permutation(4).size # => 94109400 ;TI"$loop.size # => Float::INFINITY ;TI"&(1..100).drop_while.size # => nil;T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"4e.size -> int, Float::INFINITY or nil ;T0[I"();T@FI"Enumerator;TcRDoc::NormalClass00PKJ ]Nr| Lazy/find_all-i.rinu[U:RDoc::AnyMethod[iI" find_all:ETI"Enumerator::Lazy#find_all;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#select, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[[I"_enumerable_find_all;T@ I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" select;TPKJ ]㧖Lazy/_enumerable_find_all-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_find_all:ETI"*Enumerator::Lazy#_enumerable_find_all;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#select, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" find_all;TPKJ ]^5Lazy/with_index-i.rinu[U:RDoc::AnyMethod[iI"with_index:ETI" Enumerator::Lazy#with_index;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I">If a block is given, returns a lazy enumerator that will ;TI"3iterate over the given block for each element ;TI">with an index, which starts from +offset+, and returns a ;TI"Elazy enumerator that yields the same values (without the index).;To:RDoc::Markup::BlankLineo; ; [I"AIf a block is not given, returns a new lazy enumerator that ;TI"0includes the index, starting from +offset+.;T@o:RDoc::Markup::List: @type: NOTE: @items[o:RDoc::Markup::ListItem: @label[I" +offset+;T; [o; ; [I"the starting index to use;T@o; ; [I"See Enumerator#with_index.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"Ulazy.with_index(offset = 0) {|(*args), idx| block } lazy.with_index(offset = 0) ;T0[I"(p1 = v1);T@"FI" Lazy;TcRDoc::NormalClass00PKJ ]Z Lazy/zip-i.rinu[U:RDoc::AnyMethod[iI"zip:ETI"Enumerator::Lazy#zip;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#zip, but chains operation to be lazy-evaluated. ;TI"LHowever, if a block is given to zip, values are enumerated immediately.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"glazy.zip(arg, ...) -> lazy_enumerator lazy.zip(arg, ...) { |arr| block } -> nil ;T0[[I"_enumerable_zip;T@ I" (*args);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]ӡLazy/_enumerable_filter-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_filter:ETI"(Enumerator::Lazy#_enumerable_filter;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#select, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" filter;TPKJ ]Lazy/take_while-i.rinu[U:RDoc::AnyMethod[iI"take_while:ETI" Enumerator::Lazy#take_while;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"KLike Enumerable#take_while, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"8lazy.take_while { |obj| block } -> lazy_enumerator ;T0[[I"_enumerable_take_while;T@ I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]Yc88Lazy/chunk-i.rinu[U:RDoc::AnyMethod[iI" chunk:ETI"Enumerator::Lazy#chunk;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"FLike Enumerable#chunk, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[ [I"slice_before;To;; [o; ; [I"MLike Enumerable#slice_before, but chains operation to be lazy-evaluated.;T; @; 0[I"slice_after;To;; [o; ; [I"LLike Enumerable#slice_after, but chains operation to be lazy-evaluated.;T; @; 0[I"slice_when;To;; [o; ; [I"KLike Enumerable#slice_when, but chains operation to be lazy-evaluated.;T; @; 0[I"chunk_while;To;; [o; ; [I"LLike Enumerable#chunk_while, but chains operation to be lazy-evaluated.;T; @; 0I" (*args);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]ՕLazy/filter-i.rinu[U:RDoc::AnyMethod[iI" filter:ETI"Enumerator::Lazy#filter;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#select, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[[I"_enumerable_filter;T@ I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" select;TPKJ ] ٶLazy/cdesc-Lazy.rinu[U:RDoc::NormalClass[iI" Lazy:ETI"Enumerator::Lazy;TI"Enumerator;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[ I"PEnumerator::Lazy is a special type of Enumerator, that allows constructing ;TI"Nchains of operations without evaluating them immediately, and evaluating ;TI"Rvalues on as-needed basis. In order to do so it redefines most of Enumerable ;TI"Amethods so that they just construct another lazy enumerator.;To:RDoc::Markup::BlankLineo; ;[I"FEnumerator::Lazy can be constructed from any Enumerable with the ;TI"Enumerable#lazy method.;T@o:RDoc::Markup::Verbatim;[I"Xlazy = (1..Float::INFINITY).lazy.select(&:odd?).drop(10).take_while { |i| i < 30 } ;TI"# => #:select>:drop(10)>:take_while> ;T: @format0o; ;[I"PThe real enumeration is performed when any non-redefined Enumerable method ;TI"Pis called, like Enumerable#first or Enumerable#to_a (the latter is aliased ;TI"'as #force for more semantic code):;T@o; ;[ I"lazy.first(2) ;TI"#=> [21, 23] ;TI" ;TI"lazy.force ;TI"#=> [21, 23, 25, 27, 29] ;T; 0o; ;[I"LNote that most Enumerable methods that could be called with or without ;TI">a block, on Enumerator::Lazy will always require a block:;T@o; ;[I":[1, 2, 3].map #=> # ;TI"Q[1, 2, 3].lazy.map # ArgumentError: tried to call lazy map without a block ;T; 0o; ;[I"UThis class allows idiomatic calculations on long or infinite sequences, as well ;TI"Jas chaining of calculations without constructing intermediate arrays.;T@o; ;[I";Example for working with a slowly calculated sequence:;T@o; ;[I"require 'open-uri' ;TI" ;TI"1# This will fetch all URLs before selecting ;TI"# necessary data ;TI"3URLS.map { |u| JSON.parse(URI.open(u).read) } ;TI"- .select { |data| data.key?('stats') } ;TI" .first(5) ;TI" ;TI"2# This will fetch URLs one-by-one, only till ;TI"5# there is enough data to satisfy the condition ;TI"8URLS.lazy.map { |u| JSON.parse(URI.open(u).read) } ;TI"- .select { |data| data.key?('stats') } ;TI" .first(5) ;T; 0o; ;[I"IEnding a chain with ".eager" generates a non-lazy enumerator, which ;TI"Iis suitable for returning or passing to another method that expects ;TI"a normal enumerator.;T@o; ;[I"def active_items ;TI" groups ;TI" .lazy ;TI" .flat_map(&:items) ;TI" .reject(&:disabled) ;TI" .eager ;TI" end ;TI" ;TI"?# This works lazily; if a checked item is found, it stops ;TI":# iteration and does not look into remaining groups. ;TI"2first_checked = active_items.find(&:checked) ;TI" ;TI"E# This returns an array of items like a normal enumerator does. ;TI"1all_checked = active_items.select(&:checked);T; 0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0; 0;0[[[[[I" class;T[[: public[[:protected[[: private[[I"new;TI"enumerator.c;T[I" instance;T[[;[[;[[;[5[I"_enumerable_collect;T@l[I"_enumerable_collect_concat;T@l[I"_enumerable_drop;T@l[I"_enumerable_drop_while;T@l[I"_enumerable_filter;T@l[I"_enumerable_filter_map;T@l[I"_enumerable_find_all;T@l[I"_enumerable_flat_map;T@l[I"_enumerable_grep;T@l[I"_enumerable_grep_v;T@l[I"_enumerable_map;T@l[I"_enumerable_reject;T@l[I"_enumerable_select;T@l[I"_enumerable_take;T@l[I"_enumerable_take_while;T@l[I"_enumerable_uniq;T@l[I"_enumerable_with_index;T@l[I"_enumerable_zip;T@l[I" chunk;T@l[I"chunk_while;T@l[I" collect;T@l[I"collect_concat;T@l[I" compact;T@l[I" drop;T@l[I"drop_while;T@l[I" eager;T@l[I" enum_for;T@l[I" filter;T@l[I"filter_map;T@l[I" find_all;T@l[I" flat_map;T@l[I" force;T@l[I" grep;T@l[I" grep_v;T@l[I" lazy;T@l[I"map;T@l[I" reject;T@l[I" select;T@l[I"slice_after;T@l[I"slice_before;T@l[I"slice_when;T@l[I" take;T@l[I"take_while;T@l[I" to_a;T@l[I" to_enum;T@l[I" uniq;T@l[I"with_index;T@l[I"zip;T@l[[U:RDoc::Context::Section[i0o;;[; 0;0[I"enumerator.c;TI"Enumerator;TcRDoc::NormalClassPKJ ]_\Lazy/take-i.rinu[U:RDoc::AnyMethod[iI" take:ETI"Enumerator::Lazy#take;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#take, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"3lazy.take(n) -> lazy_enumerator ;T0[[I"_enumerable_take;T@ I" (p1);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]US?? Lazy/_enumerable_filter_map-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_filter_map:ETI",Enumerator::Lazy#_enumerable_filter_map;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"KLike Enumerable#filter_map, but chains operation to be lazy-evaluated.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"=(1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5) ;TI"#=> [4, 8, 12, 16, 20];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI"filter_map;TPKJ ]8H4Lazy/to_a-i.rinu[U:RDoc::AnyMethod[iI" to_a:ETI"Enumerator::Lazy#to_a;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I",Expands +lazy+ enumerator to an array. ;TI"See Enumerable#to_a.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"-lazy.to_a -> array lazy.force -> array ;T0[[I" force;T@ I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]Zm$$Lazy/enum_for-i.rinu[U:RDoc::AnyMethod[iI" enum_for:ETI"Enumerator::Lazy#enum_for;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"ESimilar to Object#to_enum, except it returns a lazy enumerator. ;TI"?This makes it easy to define Enumerable methods that will ;TI" [1, 1, 2, 2, 3] ;TI"'r.repeat(2).class # => Enumerator ;TI"=r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop! ;TI"+# works naturally on lazy enumerator: ;TI"2r.lazy.repeat(2).class # => Enumerator::Lazy ;TI"Cr.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" to_enum;TPKJ ]fLazy/grep-i.rinu[U:RDoc::AnyMethod[iI" grep:ETI"Enumerator::Lazy#grep;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#grep, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"slazy.grep(pattern) -> lazy_enumerator lazy.grep(pattern) { |obj| block } -> lazy_enumerator ;T0[[I"_enumerable_grep;T@ I" (p1);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]ewLazy/slice_after-i.rinu[U:RDoc::AnyMethod[iI"slice_after:ETI"!Enumerator::Lazy#slice_after;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LLike Enumerable#slice_after, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" chunk;TPKJ ]ˠ Lazy/new-c.rinu[U:RDoc::AnyMethod[iI"new:ETI"Enumerator::Lazy::new;TT: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"OCreates a new Lazy enumerator. When the enumerator is actually enumerated ;TI"N(e.g. by calling #force), +obj+ will be enumerated and each value passed ;TI"Jto the given block. The block can yield values back using +yielder+. ;TI"6For example, to create a "filter+map" enumerator:;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"def filter_map(sequence) ;TI"0 Lazy.new(sequence) do |yielder, *values| ;TI" result = yield *values ;TI"% yielder << result if result ;TI" end ;TI" end ;TI" ;TI"Bfilter_map(1..Float::INFINITY) {|i| i*i if i.even?}.first(5) ;TI"#=> [4, 16, 36, 64, 100];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I":Lazy.new(obj, size=nil) { |yielder, *values| block } ;T0[I" (*args);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]iLazy/_enumerable_uniq-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_uniq:ETI"&Enumerator::Lazy#_enumerable_uniq;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#uniq, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" uniq;TPKJ ]!Lazy/_enumerable_select-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_select:ETI"(Enumerator::Lazy#_enumerable_select;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#select, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" select;TPKJ ]E8WWLazy/filter_map-i.rinu[U:RDoc::AnyMethod[iI"filter_map:ETI" Enumerator::Lazy#filter_map;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"KLike Enumerable#filter_map, but chains operation to be lazy-evaluated.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"=(1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5) ;TI"#=> [4, 8, 12, 16, 20];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"8lazy.filter_map { |obj| block } -> lazy_enumerator ;T0[[I"_enumerable_filter_map;T@ I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]Lazy/drop-i.rinu[U:RDoc::AnyMethod[iI" drop:ETI"Enumerator::Lazy#drop;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#drop, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"3lazy.drop(n) -> lazy_enumerator ;T0[[I"_enumerable_drop;T@ I" (p1);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]Lazy/to_enum-i.rinu[U:RDoc::AnyMethod[iI" to_enum:ETI"Enumerator::Lazy#to_enum;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"ESimilar to Object#to_enum, except it returns a lazy enumerator. ;TI"?This makes it easy to define Enumerable methods that will ;TI" [1, 1, 2, 2, 3] ;TI"'r.repeat(2).class # => Enumerator ;TI"=r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop! ;TI"+# works naturally on lazy enumerator: ;TI"2r.lazy.repeat(2).class # => Enumerator::Lazy ;TI"Cr.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"lzy.to_enum(method = :each, *args) -> lazy_enum lzy.enum_for(method = :each, *args) -> lazy_enum lzy.to_enum(method = :each, *args) {|*args| block } -> lazy_enum lzy.enum_for(method = :each, *args) {|*args| block } -> lazy_enum ;T0[[I" enum_for;T@ I" (*args);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]i)bLazy/collect-i.rinu[U:RDoc::AnyMethod[iI" collect:ETI"Enumerator::Lazy#collect;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DLike Enumerable#map, but chains operation to be lazy-evaluated.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"/(1..Float::INFINITY).lazy.map {|i| i**2 } ;TI"C#=> #:map> ;TI"8(1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) ;TI"#=> [1, 4, 9];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[[I"_enumerable_collect;T@ I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI"map;TPKJ ]̴{<<Lazy/lazy-i.rinu[U:RDoc::AnyMethod[iI" lazy:ETI"Enumerator::Lazy#lazy;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Returns self.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I""enum.lazy -> lazy_enumerator ;T0[I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]ұLazy/collect_concat-i.rinu[U:RDoc::AnyMethod[iI"collect_concat:ETI"$Enumerator::Lazy#collect_concat;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LReturns a new lazy enumerator with the concatenated results of running ;TI";+block+ once for every element in the lazy enumerator.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"?["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force ;TI"(#=> ["f", "o", "o", "b", "a", "r"] ;T: @format0o; ; [I"@A value +x+ returned by +block+ is decomposed if either of ;TI"&the following conditions is true:;T@o:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I";+x+ responds to both each and force, which means that ;TI"+x+ is a lazy enumerator.;To;;0; [o; ; [I"++x+ is an array or responds to to_ary.;T@o; ; [I";Otherwise, +x+ is contained as-is in the return value.;T@o; ; [I"0[{a:1}, {b:2}].lazy.flat_map {|i| i}.force ;TI"#=> [{:a=>1}, {:b=>2}];T; 0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[[I"_enumerable_collect_concat;T@ I"();T@,FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" flat_map;TPKJ ]g"J--Lazy/select-i.rinu[U:RDoc::AnyMethod[iI" select:ETI"Enumerator::Lazy#select;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#select, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"lazy.find_all { |obj| block } -> lazy_enumerator lazy.select { |obj| block } -> lazy_enumerator lazy.filter { |obj| block } -> lazy_enumerator ;T0[[I" find_all;T@ [I" filter;T@ [I"_enumerable_select;T@ I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ].\D!Lazy/_enumerable_zip-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_zip:ETI"%Enumerator::Lazy#_enumerable_zip;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#zip, but chains operation to be lazy-evaluated. ;TI"LHowever, if a block is given to zip, values are enumerated immediately.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI"zip;TPKJ ]=[iLazy/chunk_while-i.rinu[U:RDoc::AnyMethod[iI"chunk_while:ETI"!Enumerator::Lazy#chunk_while;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LLike Enumerable#chunk_while, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" chunk;TPKJ ]%Lazy/uniq-i.rinu[U:RDoc::AnyMethod[iI" uniq:ETI"Enumerator::Lazy#uniq;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#uniq, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"alazy.uniq -> lazy_enumerator lazy.uniq { |item| block } -> lazy_enumerator ;T0[[I"_enumerable_uniq;T@ I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]}X Lazy/_enumerable_with_index-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_with_index:ETI",Enumerator::Lazy#_enumerable_with_index;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DIterates the given block for each element with an index, which ;TI"Kstarts from +offset+. If no block is given, returns a new Enumerator ;TI"4that includes the index, starting from +offset+;To:RDoc::Markup::BlankLineo:RDoc::Markup::List: @type: NOTE: @items[o:RDoc::Markup::ListItem: @label[I" +offset+;T; [o; ; [I"the starting index to use;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"Me.with_index(offset = 0) {|(*args), idx| ... } e.with_index(offset = 0) ;T0[I" (*args);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]uLazy/flat_map-i.rinu[U:RDoc::AnyMethod[iI" flat_map:ETI"Enumerator::Lazy#flat_map;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LReturns a new lazy enumerator with the concatenated results of running ;TI";+block+ once for every element in the lazy enumerator.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"?["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force ;TI"(#=> ["f", "o", "o", "b", "a", "r"] ;T: @format0o; ; [I"@A value +x+ returned by +block+ is decomposed if either of ;TI"&the following conditions is true:;T@o:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I";+x+ responds to both each and force, which means that ;TI"+x+ is a lazy enumerator.;To;;0; [o; ; [I"++x+ is an array or responds to to_ary.;T@o; ; [I";Otherwise, +x+ is contained as-is in the return value.;T@o; ; [I"0[{a:1}, {b:2}].lazy.flat_map {|i| i}.force ;TI"#=> [{:a=>1}, {:b=>2}];T; 0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"wlazy.collect_concat { |obj| block } -> a_lazy_enumerator lazy.flat_map { |obj| block } -> a_lazy_enumerator ;T0[[I"collect_concat;T@ [I"_enumerable_flat_map;T@ I"();T@,FI" Lazy;TcRDoc::NormalClass00PKJ ]+p $Lazy/_enumerable_collect_concat-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_collect_concat:ETI"0Enumerator::Lazy#_enumerable_collect_concat;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LReturns a new lazy enumerator with the concatenated results of running ;TI";+block+ once for every element in the lazy enumerator.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"?["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force ;TI"(#=> ["f", "o", "o", "b", "a", "r"] ;T: @format0o; ; [I"@A value +x+ returned by +block+ is decomposed if either of ;TI"&the following conditions is true:;T@o:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I";+x+ responds to both each and force, which means that ;TI"+x+ is a lazy enumerator.;To;;0; [o; ; [I"++x+ is an array or responds to to_ary.;T@o; ; [I";Otherwise, +x+ is contained as-is in the return value.;T@o; ; [I"0[{a:1}, {b:2}].lazy.flat_map {|i| i}.force ;TI"#=> [{:a=>1}, {:b=>2}];T; 0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@,FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI"collect_concat;TPKJ ]SIlLazy/drop_while-i.rinu[U:RDoc::AnyMethod[iI"drop_while:ETI" Enumerator::Lazy#drop_while;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"KLike Enumerable#drop_while, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"9lazy.drop_while { |obj| block } -> lazy_enumerator ;T0[[I"_enumerable_drop_while;T@ I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]u Lazy/map-i.rinu[U:RDoc::AnyMethod[iI"map:ETI"Enumerator::Lazy#map;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DLike Enumerable#map, but chains operation to be lazy-evaluated.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"/(1..Float::INFINITY).lazy.map {|i| i**2 } ;TI"C#=> #:map> ;TI"8(1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) ;TI"#=> [1, 4, 9];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"elazy.collect { |obj| block } -> lazy_enumerator lazy.map { |obj| block } -> lazy_enumerator ;T0[[I" collect;T@ [I"_enumerable_map;T@ I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]FhLazy/compact-i.rinu[U:RDoc::AnyMethod[iI" compact:ETI"Enumerator::Lazy#compact;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"HLike Enumerable#compact, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"6lazy.compact -> lazy_enumerator ;T0[I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]Lazy/reject-i.rinu[U:RDoc::AnyMethod[iI" reject:ETI"Enumerator::Lazy#reject;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#reject, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"4lazy.reject { |obj| block } -> lazy_enumerator ;T0[[I"_enumerable_reject;T@ I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]gΠ Lazy/_enumerable_drop_while-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_drop_while:ETI",Enumerator::Lazy#_enumerable_drop_while;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"KLike Enumerable#drop_while, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI"drop_while;TPKJ ]/Lazy/_enumerable_collect-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_collect:ETI")Enumerator::Lazy#_enumerable_collect;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DLike Enumerable#map, but chains operation to be lazy-evaluated.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"/(1..Float::INFINITY).lazy.map {|i| i**2 } ;TI"C#=> #:map> ;TI"8(1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) ;TI"#=> [1, 4, 9];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" collect;TPKJ ]al@ggLazy/eager-i.rinu[U:RDoc::AnyMethod[iI" eager:ETI"Enumerator::Lazy#eager;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"FReturns a non-lazy Enumerator converted from the lazy enumerator.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"lzy.eager -> enum ;T0[I"();T@FI" Lazy;TcRDoc::NormalClass00PKJ ]b< Lazy/_enumerable_take_while-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_take_while:ETI",Enumerator::Lazy#_enumerable_take_while;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"KLike Enumerable#take_while, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI"take_while;TPKJ ]Ei͊Lazy/_enumerable_drop-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_drop:ETI"&Enumerator::Lazy#_enumerable_drop;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#drop, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" drop;TPKJ ]Lazy/_enumerable_grep_v-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_grep_v:ETI"(Enumerator::Lazy#_enumerable_grep_v;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#grep_v, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" grep_v;TPKJ ]ELazy/_enumerable_reject-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_reject:ETI"(Enumerator::Lazy#_enumerable_reject;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#reject, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" reject;TPKJ ]WLazy/slice_when-i.rinu[U:RDoc::AnyMethod[iI"slice_when:ETI" Enumerator::Lazy#slice_when;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"KLike Enumerable#slice_when, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" chunk;TPKJ ]n1Lazy/_enumerable_flat_map-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_flat_map:ETI"*Enumerator::Lazy#_enumerable_flat_map;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LReturns a new lazy enumerator with the concatenated results of running ;TI";+block+ once for every element in the lazy enumerator.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"?["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force ;TI"(#=> ["f", "o", "o", "b", "a", "r"] ;T: @format0o; ; [I"@A value +x+ returned by +block+ is decomposed if either of ;TI"&the following conditions is true:;T@o:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I";+x+ responds to both each and force, which means that ;TI"+x+ is a lazy enumerator.;To;;0; [o; ; [I"++x+ is an array or responds to to_ary.;T@o; ; [I";Otherwise, +x+ is contained as-is in the return value.;T@o; ; [I"0[{a:1}, {b:2}].lazy.flat_map {|i| i}.force ;TI"#=> [{:a=>1}, {:b=>2}];T; 0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@,FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" flat_map;TPKJ ]՞Lazy/_enumerable_map-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_map:ETI"%Enumerator::Lazy#_enumerable_map;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DLike Enumerable#map, but chains operation to be lazy-evaluated.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"/(1..Float::INFINITY).lazy.map {|i| i**2 } ;TI"C#=> #:map> ;TI"8(1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) ;TI"#=> [1, 4, 9];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI"map;TPKJ ]|Lazy/_enumerable_grep-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_grep:ETI"&Enumerator::Lazy#_enumerable_grep;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#grep, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" grep;TPKJ ]WttLazy/force-i.rinu[U:RDoc::AnyMethod[iI" force:ETI"Enumerator::Lazy#force;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I",Expands +lazy+ enumerator to an array. ;TI"See Enumerable#to_a.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" to_a;TPKJ ]x]Lazy/grep_v-i.rinu[U:RDoc::AnyMethod[iI" grep_v:ETI"Enumerator::Lazy#grep_v;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GLike Enumerable#grep_v, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"wlazy.grep_v(pattern) -> lazy_enumerator lazy.grep_v(pattern) { |obj| block } -> lazy_enumerator ;T0[[I"_enumerable_grep_v;T@ I" (p1);T@FI" Lazy;TcRDoc::NormalClass00PKJ ]IˎLazy/slice_before-i.rinu[U:RDoc::AnyMethod[iI"slice_before:ETI""Enumerator::Lazy#slice_before;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"MLike Enumerable#slice_before, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" chunk;TPKJ ]JFJLazy/_enumerable_take-i.rinu[U:RDoc::AnyMethod[iI"_enumerable_take:ETI"&Enumerator::Lazy#_enumerable_take;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ELike Enumerable#take, but chains operation to be lazy-evaluated.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI" take;TPKJ ]t0peek_values-i.rinu[U:RDoc::AnyMethod[iI"peek_values:ETI"Enumerator#peek_values;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"QReturns the next object as an array, similar to Enumerator#next_values, but ;TI"Pdoesn't move the internal position forward. If the position is already at ;TI"&the end, StopIteration is raised.;To:RDoc::Markup::BlankLineo; ; [I"4See class-level notes about external iterators.;T@S:RDoc::Markup::Heading: leveli: textI" Example;T@o:RDoc::Markup::Verbatim; [I"o = Object.new ;TI"def o.each ;TI" yield ;TI" yield 1 ;TI" yield 1, 2 ;TI" end ;TI"e = o.to_enum ;TI"p e.peek_values #=> [] ;TI" e.next ;TI" p e.peek_values #=> [1] ;TI" p e.peek_values #=> [1] ;TI" e.next ;TI"#p e.peek_values #=> [1, 2] ;TI" e.next ;TI".p e.peek_values # raises StopIteration;T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.peek_values -> array ;T0[I"();T@'FI"Enumerator;TcRDoc::NormalClass00PKJ ] A next-i.rinu[U:RDoc::AnyMethod[iI" next:ETI"Enumerator#next;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"OReturns the next object in the enumerator, and move the internal position ;TI"Mforward. When the position reached at the end, StopIteration is raised.;To:RDoc::Markup::BlankLineS:RDoc::Markup::Heading: leveli: textI" Example;T@o:RDoc::Markup::Verbatim; [ I"a = [1,2,3] ;TI"e = a.to_enum ;TI"p e.next #=> 1 ;TI"p e.next #=> 2 ;TI"p e.next #=> 3 ;TI"&p e.next #raises StopIteration ;T: @format0o; ; [I"4See class-level notes about external iterators.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.next -> object ;T0[I"();T@FI"Enumerator;TcRDoc::NormalClass00PKJ ]lArithmeticSequence/inspect-i.rinu[U:RDoc::AnyMethod[iI" inspect:ETI"+Enumerator::ArithmeticSequence#inspect;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I":Convert this arithmetic sequence to a printable form.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"aseq.inspect -> string ;T0[I"();T@FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]2GArithmeticSequence/step-i.rinu[U:RDoc::AnyMethod[iI" step:ETI"(Enumerator::ArithmeticSequence#step;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ])UArithmeticSequence/first-i.rinu[U:RDoc::AnyMethod[iI" first:ETI")Enumerator::ArithmeticSequence#first;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I";Returns the first number in this arithmetic sequence, ;TI"+or an array of the first +n+ elements.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"8aseq.first -> num or nil aseq.first(n) -> an_array ;T0[I" (*args);T@FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]Y>)ArithmeticSequence/eql%3f-i.rinu[U:RDoc::AnyMethod[iI" eql?:ETI"(Enumerator::ArithmeticSequence#eql?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"SReturns true only if +obj+ is an Enumerator::ArithmeticSequence, ;TI"@has equivalent begin, end, step, and exclude_end? settings.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1);T@FI"ArithmeticSequence;TcRDoc::NormalClass0[I"#Enumerator::ArithmeticSequence;TFI"==;TPKJ ]MoArithmeticSequence/begin-i.rinu[U:RDoc::AnyMethod[iI" begin:ETI")Enumerator::ArithmeticSequence#begin;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]P"ArithmeticSequence/end-i.rinu[U:RDoc::AnyMethod[iI"end:ETI"'Enumerator::ArithmeticSequence#end;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ] ArithmeticSequence/size-i.rinu[U:RDoc::AnyMethod[iI" size:ETI"(Enumerator::ArithmeticSequence#size;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"RReturns the number of elements in this arithmetic sequence if it is a finite ;TI"4sequence. Otherwise, returns nil.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"aseq.size -> num or nil ;T0[I"();T@FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]OEArithmeticSequence/last-i.rinu[U:RDoc::AnyMethod[iI" last:ETI"(Enumerator::ArithmeticSequence#last;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I":Returns the last number in this arithmetic sequence, ;TI"*or an array of the last +n+ elements.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"9aseq.last -> num or nil aseq.last(n) -> an_array ;T0[I" (p1);T@FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]!ArithmeticSequence/%3d%3d%3d-i.rinu[U:RDoc::AnyMethod[iI"===:ETI"'Enumerator::ArithmeticSequence#===;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"SReturns true only if +obj+ is an Enumerator::ArithmeticSequence, ;TI"@has equivalent begin, end, step, and exclude_end? settings.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1);T@FI"ArithmeticSequence;TcRDoc::NormalClass0[I"#Enumerator::ArithmeticSequence;TFI"==;TPKJ ]+$$.ArithmeticSequence/cdesc-ArithmeticSequence.rinu[U:RDoc::NormalClass[iI"ArithmeticSequence:ETI"#Enumerator::ArithmeticSequence;TI"Enumerator;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[ I"AEnumerator::ArithmeticSequence is a subclass of Enumerator, ;TI"Nthat is a representation of sequences of numbers with common difference. ;TI"QInstances of this class can be generated by the Range#step and Numeric#step ;TI" methods.;To:RDoc::Markup::BlankLineo; ;[I"IThe class can be used for slicing Array (see Array#slice) or custom ;TI"collections.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[;[[;[[I"==;TI"enumerator.c;T[I"===;T@2[I" begin;T@2[I" each;T@2[I"end;T@2[I" eql?;T@2[I"exclude_end?;T@2[I" first;T@2[I" hash;T@2[I" inspect;T@2[I" last;T@2[I" size;T@2[I" step;T@2[[U:RDoc::Context::Section[i0o;;[; 0; 0[I"enumerator.c;TI"Enumerator;TcRDoc::NormalClassPKJ ] %{EEArithmeticSequence/each-i.rinu[U:RDoc::AnyMethod[iI" each:ETI"(Enumerator::ArithmeticSequence#each;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"Baseq.each {|i| block } -> aseq aseq.each -> aseq;T0[I"();T@ FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]f5ArithmeticSequence/%3d%3d-i.rinu[U:RDoc::AnyMethod[iI"==:ETI"&Enumerator::ArithmeticSequence#==;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"SReturns true only if +obj+ is an Enumerator::ArithmeticSequence, ;TI"@has equivalent begin, end, step, and exclude_end? settings.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"#aseq == obj -> true or false ;T0[[I"===;T@ [I" eql?;T@ I" (p1);T@FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]t&ArithmeticSequence/exclude_end%3f-i.rinu[U:RDoc::AnyMethod[iI"exclude_end?:ETI"0Enumerator::ArithmeticSequence#exclude_end?;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]vcg33ArithmeticSequence/hash-i.rinu[U:RDoc::AnyMethod[iI" hash:ETI"(Enumerator::ArithmeticSequence#hash;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"8Compute a hash-value for this arithmetic sequence. ;TI"KTwo arithmetic sequences with same begin, end, step, and exclude_end? ;TI".values will generate the same hash-value.;To:RDoc::Markup::BlankLineo; ; [I"See also Object#hash.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"aseq.hash -> integer ;T0[I"();T@FI"ArithmeticSequence;TcRDoc::NormalClass00PKJ ]--cdesc-Enumerator.rinu[U:RDoc::NormalClass[iI"Enumerator:ET@I" Object;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"?A class which allows both internal and external iteration.;To:RDoc::Markup::BlankLineo; ;[I";An Enumerator can be created by the following methods.;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0;[o; ;[I"Object#to_enum;To;;0;[o; ;[I"Object#enum_for;To;;0;[o; ;[I"Enumerator.new;T@o; ;[I"BMost methods have two forms: a block form where the contents ;TI"Jare evaluated for each item in the enumeration, and a non-block form ;TI";which returns a new Enumerator wrapping the iteration.;T@o:RDoc::Markup::Verbatim;[I")enumerator = %w(one two three).each ;TI"+puts enumerator.class # => Enumerator ;TI" ;TI"7enumerator.each_with_object("foo") do |item, obj| ;TI" puts "#{obj}: #{item}" ;TI" end ;TI" ;TI"# foo: one ;TI"# foo: two ;TI"# foo: three ;TI" ;TI"8enum_with_obj = enumerator.each_with_object("foo") ;TI".puts enum_with_obj.class # => Enumerator ;TI" ;TI"'enum_with_obj.each do |item, obj| ;TI" puts "#{obj}: #{item}" ;TI" end ;TI" ;TI"# foo: one ;TI"# foo: two ;TI"# foo: three ;T: @format0o; ;[I"FThis allows you to chain Enumerators together. For example, you ;TI"?can map a list's elements to strings containing the index ;TI"%and the element as a string via:;T@o;;[I"@puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" } ;TI"&# => ["0:foo", "1:bar", "2:baz"] ;T;0o; ;[I"=An Enumerator can also be used as an external iterator. ;TI"IFor example, Enumerator#next returns the next value of the iterator ;TI"=or raises StopIteration if the Enumerator is at the end.;T@o;;[ I"8e = [1,2,3].each # returns an enumerator object. ;TI"puts e.next # => 1 ;TI"puts e.next # => 2 ;TI"puts e.next # => 3 ;TI"*puts e.next # raises StopIteration ;T;0o; ;[ I"INote that enumeration sequence by +next+, +next_values+, +peek+ and ;TI"4+peek_values+ do not affect other non-external ;TI"Lenumeration methods, unless the underlying iteration method itself has ;TI"$side-effect, e.g. IO#each_line.;T@o; ;[I"LMoreover, implementation typically uses fibers so performance could be ;TI">slower and exception stacktraces different than expected.;T@o; ;[I"CYou can use this to implement an internal iterator as follows:;T@o;;["I"def ext_each(e) ;TI" while true ;TI" begin ;TI" vs = e.next_values ;TI" rescue StopIteration ;TI" return $!.result ;TI" end ;TI" y = yield(*vs) ;TI" e.feed y ;TI" end ;TI" end ;TI" ;TI"o = Object.new ;TI" ;TI"def o.each ;TI" puts yield ;TI" puts yield(1) ;TI" puts yield(1, 2) ;TI" 3 ;TI" end ;TI" ;TI"4# use o.each as an internal iterator directly. ;TI"*puts o.each {|*x| puts x; [:b, *x] } ;TI"8# => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3 ;TI" ;TI"2# convert o.each to an external iterator for ;TI"*# implementing an internal iterator. ;TI"7puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] } ;TI"7# => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3;T;0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0;0;0[[[[I"Enumerable;To;;[;@};0I"enumerator.c;T[[I" class;T[[: public[[:protected[[: private[[I"new;T@[I" produce;T@[I" instance;T[[;[[;[[;[[I"+;T@[I" each;T@[I"each_with_index;T@[I"each_with_object;T@[I" feed;T@[I" inspect;T@[I" next;T@[I"next_values;T@[I" peek;T@[I"peek_values;T@[I" rewind;T@[I" size;T@[I"with_index;T@[I"with_object;T@[[U:RDoc::Context::Section[i0o;;[;0;0[I"enumerator.c;T@}cRDoc::TopLevelPKJ ]!~f** produce-c.rinu[U:RDoc::AnyMethod[iI" produce:ETI"Enumerator::produce;TT: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I"ICreates an infinite enumerator from any block, just called over and ;TI"Lover. The result of the previous iteration is passed to the next one. ;TI"HIf +initial+ is provided, it is passed to the first iteration, and ;TI"Ibecomes the first element of the enumerator; if it is not provided, ;TI"Jthe first iteration receives +nil+, and its result becomes the first ;TI"element of the iterator.;To:RDoc::Markup::BlankLineo; ; [I"=Raising StopIteration from the block stops an iteration.;T@o:RDoc::Markup::Verbatim; [ I"IEnumerator.produce(1, &:succ) # => enumerator of 1, 2, 3, 4, .... ;TI" ;TI"JEnumerator.produce { rand(10) } # => infinite random number sequence ;TI" ;TI"_ancestors = Enumerator.produce(node) { |prev| node = prev.parent or raise StopIteration } ;TI"Cenclosing_section = ancestors.find { |n| n.type == :section } ;T: @format0o; ; [I"NUsing ::produce together with Enumerable methods like Enumerable#detect, ;TI"]Enumerable#slice_after, Enumerable#take_while can provide Enumerator-based alternatives ;TI"$for +while+ and +until+ cycles:;T@o; ; [I"# Find next Tuesday ;TI"require "date" ;TI"?Enumerator.produce(Date.today, &:succ).detect(&:tuesday?) ;TI" ;TI"# Simple lexer: ;TI"require "strscan" ;TI"+scanner = StringScanner.new("7+38/6") ;TI"PATTERN = %r{\d+|[-/+*]} ;TI"UEnumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first ;TI"$# => ["7", "+", "38", "/", "6"];T; 0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"FEnumerator.produce(initial = nil) { |prev| block } -> enumerator ;T0[I"(p1 = v1);T@0FI"Enumerator;TcRDoc::NormalClass00PKJ ]eڎswith_object-i.rinu[U:RDoc::AnyMethod[iI"with_object:ETI"Enumerator#with_object;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"PIterates the given block for each element with an arbitrary object, +obj+, ;TI"and returns +obj+;To:RDoc::Markup::BlankLineo; ; [I"4If no block is given, returns a new Enumerator.;T@S:RDoc::Markup::Heading: leveli: textI" Example;T@o:RDoc::Markup::Verbatim; [I"&to_three = Enumerator.new do |y| ;TI" 3.times do |x| ;TI" y << x ;TI" end ;TI" end ;TI" ;TI"8to_three_with_string = to_three.with_object("foo") ;TI"-to_three_with_string.each do |x,string| ;TI" puts "#{string}: #{x}" ;TI" end ;TI" ;TI"# => foo: 0 ;TI"# => foo: 1 ;TI"# => foo: 2;T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1);T@%FI"Enumerator;TcRDoc::NormalClass0[@(FI"each_with_object;TPKJ ]Mk rewind-i.rinu[U:RDoc::AnyMethod[iI" rewind:ETI"Enumerator#rewind;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"7Rewinds the enumeration sequence to the beginning.;To:RDoc::Markup::BlankLineo; ; [I"HIf the enclosed object responds to a "rewind" method, it is called.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.rewind -> e ;T0[I"();T@FI"Enumerator;TcRDoc::NormalClass00PKJ ]O%2b-i.rinu[U:RDoc::AnyMethod[iI"+:ETI"Enumerator#+;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GReturns an enumerator object generated from this enumerator and a ;TI"given enumerable.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"e = (1..3).each + [4, 5] ;TI"e.to_a #=> [1, 2, 3, 4, 5];T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e + enum -> enumerator ;T0[I" (p1);T@FI"Enumerator;TcRDoc::NormalClass00PKJ ]#Generator/cdesc-Generator.rinu[U:RDoc::NormalClass[iI"Generator:ETI"Enumerator::Generator;TI" Object;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"Generator;To:RDoc::Markup::BlankLine: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[I"Enumerable;To;;[; @; 0I"enumerator.c;T[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[;[[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[I"enumerator.c;TI"Enumerator;TcRDoc::NormalClassPKJ ]J{ each-i.rinu[U:RDoc::AnyMethod[iI" each:ETI"Enumerator#each;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"OIterates over the block according to how this Enumerator was constructed. ;TI":If no block and no arguments are given, returns self.;To:RDoc::Markup::BlankLineS:RDoc::Markup::Heading: leveli: textI" Examples;T@o:RDoc::Markup::Verbatim; [I"L"Hello, world!".scan(/\w+/) #=> ["Hello", "world"] ;TI"L"Hello, world!".to_enum(:scan, /\w+/).to_a #=> ["Hello", "world"] ;TI"L"Hello, world!".to_enum(:scan).each(/\w+/).to_a #=> ["Hello", "world"] ;TI" ;TI"obj = Object.new ;TI" ;TI"&def obj.each_arg(a, b=:b, *rest) ;TI" yield a ;TI" yield b ;TI" yield rest ;TI" :method_returned ;TI" end ;TI" ;TI"*enum = obj.to_enum :each_arg, :a, :x ;TI" ;TI"6enum.each.to_a #=> [:a, :x, []] ;TI".enum.each.equal?(enum) #=> true ;TI":enum.each { |elm| elm } #=> :method_returned ;TI" ;TI" [:a, :x, [:y, :z]] ;TI"/enum.each(:y, :z).equal?(enum) #=> false ;TI"9enum.each(:y, :z) { |elm| elm } #=> :method_returned;T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"enum.each { |elm| block } -> obj enum.each -> enum enum.each(*appending_args) { |elm| block } -> obj enum.each(*appending_args) -> an_enumerator ;T0[I" (*args);T@*FI"Enumerator;TcRDoc::NormalClass00PKJ ]veach_with_index-i.rinu[U:RDoc::AnyMethod[iI"each_with_index:ETI"Enumerator#each_with_index;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"HSame as Enumerator#with_index(0), i.e. there is no starting offset.;To:RDoc::Markup::BlankLineo; ; [I"PIf no block is given, a new Enumerator is returned that includes the index.;T: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"?e.each_with_index {|(*args), idx| ... } e.each_with_index ;T0[I"();T@FI"Enumerator;TcRDoc::NormalClass00PKJ ]55lww feed-i.rinu[U:RDoc::AnyMethod[iI" feed:ETI"Enumerator#feed;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"@Sets the value to be returned by the next yield inside +e+.;To:RDoc::Markup::BlankLineo; ; [I"4If the value is not set, the yield returns nil.;T@o; ; [I"/This value is cleared after being yielded.;T@o:RDoc::Markup::Verbatim; ['I"I# Array#map passes the array's elements to "yield" and collects the ;TI"'# results of "yield" as an array. ;TI"K# Following example shows that "next" returns the passed elements and ;TI"F# values passed to "feed" are collected as an array which can be ;TI")# obtained by StopIteration#result. ;TI"e = [1,2,3].map ;TI"p e.next #=> 1 ;TI"e.feed "a" ;TI"p e.next #=> 2 ;TI"e.feed "b" ;TI"p e.next #=> 3 ;TI"e.feed "c" ;TI" begin ;TI" e.next ;TI"rescue StopIteration ;TI", p $!.result #=> ["a", "b", "c"] ;TI" end ;TI" ;TI"o = Object.new ;TI"def o.each ;TI"& x = yield # (2) blocks ;TI"( p x # (5) => "foo" ;TI"& x = yield # (6) blocks ;TI"& p x # (8) => nil ;TI"& x = yield # (9) blocks ;TI": p x # not reached w/o another e.next ;TI" end ;TI" ;TI"e = o.to_enum ;TI"e.next # (1) ;TI"e.feed "foo" # (3) ;TI"e.next # (4) ;TI"e.next # (7) ;TI" # (10);T: @format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.feed obj -> nil ;T0[I" (p1);T@9FI"Enumerator;TcRDoc::NormalClass00PKJ ]jUwith_index-i.rinu[PKJ ]AProducer/cdesc-Producer.rinu[PKJ ]"UU @inspect-i.rinu[PKJ ]{]ddChain/inspect-i.rinu[PKJ ]ҋVVwChain/new-c.rinu[PKJ ]33 Chain/size-i.rinu[PKJ ]HU} Chain/rewind-i.rinu[PKJ ] Chain/each-i.rinu[PKJ ]F]uChain/cdesc-Chain.rinu[PKJ ]cYielder/cdesc-Yielder.rinu[PKJ ] Yielder/to_proc-i.rinu[PKJ ]pK44 new-c.rinu[PKJ ]ahh wpeek-i.rinu[PKJ ]D))#each_with_object-i.rinu[PKJ ]ߝ>'next_values-i.rinu[PKJ ]]WW |-size-i.rinu[PKJ ]Nr|  0Lazy/find_all-i.rinu[PKJ ]㧖1Lazy/_enumerable_find_all-i.rinu[PKJ ]^53Lazy/with_index-i.rinu[PKJ ]Z 7Lazy/zip-i.rinu[PKJ ]ӡ(:Lazy/_enumerable_filter-i.rinu[PKJ ]<Lazy/take_while-i.rinu[PKJ ]Yc88>Lazy/chunk-i.rinu[PKJ ]ՕwALazy/filter-i.rinu[PKJ ] ٶLCLazy/cdesc-Lazy.rinu[PKJ ]_\DTLazy/take-i.rinu[PKJ ]US?? VLazy/_enumerable_filter_map-i.rinu[PKJ ]8H4XLazy/to_a-i.rinu[PKJ ]Zm$$xZLazy/enum_for-i.rinu[PKJ ]f^Lazy/grep-i.rinu[PKJ ]ew`Lazy/slice_after-i.rinu[PKJ ]ˠ bLazy/new-c.rinu[PKJ ]ifLazy/_enumerable_uniq-i.rinu[PKJ ]!hLazy/_enumerable_select-i.rinu[PKJ ]E8WW~jLazy/filter_map-i.rinu[PKJ ]mLazy/drop-i.rinu[PKJ ]nLazy/to_enum-i.rinu[PKJ ]i)bStLazy/collect-i.rinu[PKJ ]̴{<<-wLazy/lazy-i.rinu[PKJ ]ұxLazy/collect_concat-i.rinu[PKJ ]g"J--}Lazy/select-i.rinu[PKJ ].\D! Lazy/_enumerable_zip-i.rinu[PKJ ]=[i.Lazy/chunk_while-i.rinu[PKJ ]%Lazy/uniq-i.rinu[PKJ ]}X Lazy/_enumerable_with_index-i.rinu[PKJ ]uALazy/flat_map-i.rinu[PKJ ]+p $Lazy/_enumerable_collect_concat-i.rinu[PKJ ]SIlLazy/drop_while-i.rinu[PKJ ]u Lazy/map-i.rinu[PKJ ]FhLazy/compact-i.rinu[PKJ ]rLazy/reject-i.rinu[PKJ ]gΠ VLazy/_enumerable_drop_while-i.rinu[PKJ ]/FLazy/_enumerable_collect-i.rinu[PKJ ]al@gg*Lazy/eager-i.rinu[PKJ ]b< ТLazy/_enumerable_take_while-i.rinu[PKJ ]Ei͊Lazy/_enumerable_drop-i.rinu[PKJ ]Lazy/_enumerable_grep_v-i.rinu[PKJ ]ErLazy/_enumerable_reject-i.rinu[PKJ ]WNLazy/slice_when-i.rinu[PKJ ]n1Lazy/_enumerable_flat_map-i.rinu[PKJ ]՞Lazy/_enumerable_map-i.rinu[PKJ ]|ԳLazy/_enumerable_grep-i.rinu[PKJ ]WttLazy/force-i.rinu[PKJ ]x][Lazy/grep_v-i.rinu[PKJ ]IˎLazy/slice_before-i.rinu[PKJ ]JFJXLazy/_enumerable_take-i.rinu[PKJ ]t0,peek_values-i.rinu[PKJ ] A next-i.rinu[PKJ ]lArithmeticSequence/inspect-i.rinu[PKJ ]2GArithmeticSequence/step-i.rinu[PKJ ])UArithmeticSequence/first-i.rinu[PKJ ]Y>)ArithmeticSequence/eql%3f-i.rinu[PKJ ]Mo;ArithmeticSequence/begin-i.rinu[PKJ ]P"ArithmeticSequence/end-i.rinu[PKJ ] ArithmeticSequence/size-i.rinu[PKJ ]OEArithmeticSequence/last-i.rinu[PKJ ]!ArithmeticSequence/%3d%3d%3d-i.rinu[PKJ ]+$$.6ArithmeticSequence/cdesc-ArithmeticSequence.rinu[PKJ ] %{EEArithmeticSequence/each-i.rinu[PKJ ]f5IArithmeticSequence/%3d%3d-i.rinu[PKJ ]t&ArithmeticSequence/exclude_end%3f-i.rinu[PKJ ]vcg33ArithmeticSequence/hash-i.rinu[PKJ ]--ucdesc-Enumerator.rinu[PKJ ]!~f** produce-c.rinu[PKJ ]eڎsKwith_object-i.rinu[PKJ ]Mk &rewind-i.rinu[PKJ ]O&%2b-i.rinu[PKJ ]#aGenerator/cdesc-Generator.rinu[PKJ ]J{ each-i.rinu[PKJ ]v each_with_index-i.rinu[PKJ ]55lww { feed-i.rinu[PK[[7+