ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
PK #]xo#
find_all-i.rinu [ U:RDoc::AnyMethod[iI"
find_all:ETI"Enumerable#find_all;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"8Returns an array containing all elements of +enum+ ;TI"6for which the given +block+ returns a true value.;To:RDoc::Markup::BlankLine o;
; [I"=If no block is given, an Enumerator is returned instead.;T@o:RDoc::Markup::Verbatim; [I":(1..10).find_all { |i| i % 3 == 0 } #=> [3, 6, 9]
;TI"
;TI";[1,2,3,4,5].select { |num| num.even? } #=> [2, 4]
;T:@format0o;
; [I" See also Enumerable#reject.;T:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Zenum.find_all { |obj| block } -> array
enum.find_all -> an_enumerator;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #]/ zip-i.rinu [ U:RDoc::AnyMethod[iI"zip:ETI"Enumerable#zip;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I"ATakes one element from enum and merges corresponding ;TI"Celements from each args. This generates a sequence of ;TI"Fn-element arrays, where n is one more than the ;TI"Gcount of arguments. The length of the resulting sequence will be ;TI"Genum#size. If the size of any argument is less than ;TI"Fenum#size, nil values are supplied. If ;TI"Fa block is given, it is invoked for each output array, otherwise ;TI"$an array of arrays is returned.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"a = [ 4, 5, 6 ]
;TI"b = [ 7, 8, 9 ]
;TI"
;TI"D[1, 2, 3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
;TI"9[1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]]
;TI"Ia.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"ienum.zip(arg, ...) -> an_array_of_array
enum.zip(arg, ...) { |arr| block } -> nil
;T0[ I"(*args);T@FI"Enumerable;TcRDoc::NormalModule00PK #]?$& minmax_by-i.rinu [ U:RDoc::AnyMethod[iI"minmax_by:ETI"Enumerable#minmax_by;TF:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [I";Returns a two element array containing the objects in ;TI"Penum that correspond to the minimum and maximum values respectively ;TI"from the given block.;To:RDoc::Markup::BlankLine o;
; [I"=If no block is given, an enumerator is returned instead.;T@o:RDoc::Markup::Verbatim; [I"!a = %w(albatross dog horse)
;TI" ["dog", "albatross"];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"benum.minmax_by { |obj| block } -> [min, max]
enum.minmax_by -> an_enumerator
;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #]Y take_while-i.rinu [ U:RDoc::AnyMethod[iI"take_while:ETI"Enumerable#take_while;TF:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [I"LPasses elements to the block until the block returns +nil+ or +false+, ;TI"Ethen stops iterating and returns an array of all prior elements.;To:RDoc::Markup::BlankLine o;
; [I"=If no block is given, an enumerator is returned instead.;T@o:RDoc::Markup::Verbatim; [I"a = [1, 2, 3, 4, 5, 0]
;TI",a.take_while { |i| i < 3 } #=> [1, 2];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"_enum.take_while { |arr| block } -> array
enum.take_while -> an_enumerator
;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #]ڇz z
chunk-i.rinu [ U:RDoc::AnyMethod[iI"
chunk:ETI"Enumerable#chunk;TF:publico:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Paragraph; [I"KEnumerates over the items, chunking them together based on the return ;TI"value of the block.;To:RDoc::Markup::BlankLine o;
; [I"QConsecutive elements which return the same block value are chunked together.;T@o;
; [I"BFor example, consecutive even numbers and odd numbers can be ;TI"chunked as follows.;T@o:RDoc::Markup::Verbatim; [I"3[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5].chunk { |n|
;TI" n.even?
;TI"}.each { |even, ary|
;TI" p [even, ary]
;TI"}
;TI"#=> [false, [3, 1]]
;TI"# [true, [4]]
;TI"# [false, [1, 5, 9]]
;TI"# [true, [2, 6]]
;TI"# [false, [5, 3, 5]]
;T:@format0o;
; [I"EThis method is especially useful for sorted series of elements. ;TI"@The following example counts words for each initial letter.;T@o;; [I"9open("/usr/share/dict/words", "r:iso-8859-1") { |f|
;TI"Q f.chunk { |line| line.ord }.each { |ch, lines| p [ch.chr, lines.length] }
;TI"}
;TI"#=> ["\n", 1]
;TI"# ["A", 1327]
;TI"# ["B", 1372]
;TI"# ["C", 1507]
;TI"# ["D", 791]
;TI"
# ...
;T;
0o;
; [I"3The following key values have special meaning:;To:RDoc::Markup::List:
@type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o;
; [I"K+nil+ and +:_separator+ specifies that the elements should be dropped.;To;;0; [o;
; [I"F+:_alone+ specifies that the element should be chunked by itself.;T@o;
; [I"IAny other symbols that begin with an underscore will raise an error:;T@o;; [I")items.chunk { |item| :_underscore }
;TI"I#=> RuntimeError: symbols beginning with an underscore are reserved
;T;
0o;
; [I"A+nil+ and +:_separator+ can be used to ignore some elements.;T@o;
; [I"RFor example, the sequence of hyphens in svn log can be eliminated as follows:;T@o;; [I"sep = "-"*72 + "\n"
;TI"&IO.popen("svn log README") { |f|
;TI" f.chunk { |line|
;TI" line != sep || nil
;TI" }.each { |_, lines|
;TI" pp lines
;TI" }
;TI"}
;TI"U#=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n",
;TI"# "\n",
;TI"D# "* README, README.ja: Update the portability section.\n",
;TI"# "\n"]
;TI"U# ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n",
;TI"# "\n",
;TI"F# "* README, README.ja: Add a note about default C flags.\n",
;TI"# "\n"]
;TI"
# ...
;T;
0o;
; [I"BParagraphs separated by empty lines can be parsed as follows:;T@o;; [
I"+File.foreach("README").chunk { |line|
;TI" /\A\s*\z/ !~ line || nil
;TI"}.each { |_, lines|
;TI" pp lines
;TI"}
;T;
0o;
; [I"@+:_alone+ can be used to force items into their own chunk. ;TI"FFor example, you can put lines that contain a URL by themselves, ;TI"9and chunk the rest of the lines together, like this:;T@o;; [I"pattern = /http/
;TI"open(filename) { |f|
;TI"O f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines|
;TI" pp lines
;TI" }
;TI"}
;T;
0o;
; [
I"BIf the block needs to maintain state over multiple elements, ;TI".an +initial_state+ argument can be used. ;TI""If a non-nil value is given, ;TI"Ja reference to it is passed as the 2nd argument of the block for the ;TI"G+chunk+ method, so state-changes to it persist across block calls.;T:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"enum.chunk { |elt| ... } -> an_enumerator
enum.chunk(initial_state) { |elt, state| ... } -> an_enumerator
;T0[ I"(p1 = v1);T@FI"Enumerable;TcRDoc::NormalModule00PK #] S S filter-i.rinu [ U:RDoc::AnyMethod[iI"filter:ETI"Enumerable#filter;TF:privateo:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [I"@Returns an array containing elements selected by the block.;To:RDoc::Markup::BlankLine o;
; [I"CWith a block given, calls the block with successive elements; ;TI"Sreturns an array of those elements for which the block returns a truthy value:;T@o:RDoc::Markup::Verbatim; [I"C(0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9]
;TI"Na = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') }
;TI"a # => {:bar=>1, :baz=>2}
;T:@format0o;
; [I"1With no block given, returns an \Enumerator.;T@o;
; [I"Related: #reject.;T:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below000[ I"();T@FI"Enumerable;TcRDoc::NormalModule0[@!FI"
find_all;TPK #] take-i.rinu [ U:RDoc::AnyMethod[iI" take:ETI"Enumerable#take;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"/Returns first n elements from enum.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"a = [1, 2, 3, 4, 5, 0]
;TI"(a.take(3) #=> [1, 2, 3];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I")enum.take(n) -> array
;T0[ I" (p1);T@FI"Enumerable;TcRDoc::NormalModule00PK #]0h reduce-i.rinu [ U:RDoc::AnyMethod[iI"reduce:ETI"Enumerable#reduce;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"?Combines all elements of enum by applying a binary ;TI">operation, specified by a block or a symbol that names a ;TI"method or operator.;To:RDoc::Markup::BlankLine o;
; [I"BIf you specify a block, then for each element in enum ;TI"Mthe block is passed an accumulator value (memo) and the element. ;TI"JIf you specify a symbol instead, then each element in the collection ;TI"8will be passed to the named method of memo. ;TI"GIn either case, the result becomes the new value for memo. ;TI"HAt the end of the iteration, the final value of memo is the ;TI"!return value for the method.;T@o;
; [I"OIf you do not explicitly specify an initial value for memo, ;TI"Gthen the first element of collection is used as the initial value ;TI"of memo.;T@o:RDoc::Markup::Verbatim; [I"# Sum some numbers
;TI";(5..10).reduce(:+) #=> 45
;TI"%# Same using a block and inject
;TI";(5..10).inject { |sum, n| sum + n } #=> 45
;TI"# Multiply some numbers
;TI"?(5..10).reduce(1, :*) #=> 151200
;TI"# Same using a block
;TI"?(5..10).inject(1) { |product, n| product * n } #=> 151200
;TI"# find the longest word
;TI";longest = %w{ cat sheep bear }.inject do |memo, word|
;TI"0 memo.length > word.length ? memo : word
;TI" end
;TI"?longest #=> "sheep";T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"enum.reduce(initial, sym) -> obj
enum.reduce(sym) -> obj
enum.reduce(initial) { |memo, obj| block } -> obj
enum.reduce { |memo, obj| block } -> obj;T0[ I"(p1 = v1, p2 = v2);T@.FI"Enumerable;TcRDoc::NormalModule00PK #]#vi to_a-i.rinu [ U:RDoc::AnyMethod[iI" to_a:ETI"Enumerable#to_a;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I":Returns an array containing the items in enum.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [
I"A(1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
;TI"J{ 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
;TI"
;TI"require 'prime'
;TI"7Prime.entries 10 #=> [2, 3, 5, 7];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"#enum.to_a(*args) -> array;T0[ I"(*args);T@FI"Enumerable;TcRDoc::NormalModule00PK #]
first-i.rinu [ U:RDoc::AnyMethod[iI"
first:ETI"Enumerable#first;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"NReturns the first element, or the first +n+ elements, of the enumerable. ;TI"RIf the enumerable is empty, the first form returns nil, and the ;TI"(second form returns an empty array.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [ I")%w[foo bar baz].first #=> "foo"
;TI"2%w[foo bar baz].first(2) #=> ["foo", "bar"]
;TI"9%w[foo bar baz].first(10) #=> ["foo", "bar", "baz"]
;TI"&[].first #=> nil;T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Cenum.first -> obj or nil
enum.first(n) -> an_array
;T0[ I"(*args);T@FI"Enumerable;TcRDoc::NormalModule00PK #]ư grep-i.rinu [ U:RDoc::AnyMethod[iI" grep:ETI"Enumerable#grep;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"@Returns an array of every element in enum for which ;TI"IPattern === element. If the optional block is ;TI"Fsupplied, each matching element is passed to it, and the block's ;TI"*result is stored in the output array.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [
I"=(1..100).grep 38..44 #=> [38, 39, 40, 41, 42, 43, 44]
;TI"c = IO.constants
;TI"Bc.grep(/SEEK/) #=> [:SEEK_SET, :SEEK_CUR, :SEEK_END]
;TI"2res = c.grep(/SEEK/) { |v| IO.const_get(v) }
;TI")res #=> [0, 1, 2];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"_enum.grep(pattern) -> array
enum.grep(pattern) { |obj| block } -> array
;T0[ I" (p1);T@FI"Enumerable;TcRDoc::NormalModule00PK #]e
group_by-i.rinu [ U:RDoc::AnyMethod[iI"
group_by:ETI"Enumerable#group_by;TF:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [I"MGroups the collection by result of the block. Returns a hash where the ;TI"Ekeys are the evaluated result from the block and the values are ;TI"Earrays of elements in the collection that correspond to the key.;To:RDoc::Markup::BlankLine o;
; [I"4If no block is given an enumerator is returned.;T@o:RDoc::Markup::Verbatim; [I"H(1..6).group_by { |i| i%3 } #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]};T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"\enum.group_by { |obj| block } -> a_hash
enum.group_by -> an_enumerator
;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #]{ { slice_after-i.rinu [ U:RDoc::AnyMethod[iI"slice_after:ETI"Enumerable#slice_after;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"6Creates an enumerator for each chunked elements. ;TI"?The ends of chunks are defined by _pattern_ and the block.;To:RDoc::Markup::BlankLine o;
; [I"PIf _pattern_ === _elt_ returns true or the block ;TI"Hreturns true for the element, the element is end of a ;TI"chunk.;T@o;
; [I"SThe === and _block_ is called from the first element to the last ;TI"element of _enum_.;T@o;
; [I"DThe result enumerator yields the chunked elements as an array. ;TI"/So +each+ method can be called as follows:;T@o:RDoc::Markup::Verbatim; [I"2enum.slice_after(pattern).each { |ary| ... }
;TI"8enum.slice_after { |elt| bool }.each { |ary| ... }
;T:@format0o;
; [I"BOther methods of the Enumerator class and Enumerable module, ;TI"*such as +map+, etc., are also usable.;T@o;
; [I"GFor example, continuation lines (lines end with backslash) can be ;TI"concatenated as follows:;T@o;; [I":lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"]
;TI"*e = lines.slice_after(/(?#=> [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]]
;TI"Np e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last }
;TI",#=>["foo\n", "barbaz\n", "\n", "qux\n"];T;
0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"genum.slice_after(pattern) -> an_enumerator
enum.slice_after { |elt| bool } -> an_enumerator
;T0[ I" (p1);T@1FI"Enumerable;TcRDoc::NormalModule00PK #]G sort-i.rinu [ U:RDoc::AnyMethod[iI" sort:ETI"Enumerable#sort;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"BReturns an array containing the items in enum sorted, ;TI"Heither according to their own <=> method, or by using ;TI"Jthe results of the supplied block. The block should return -1, 0, or ;TI"I+1 depending on the comparison between a and b. As of ;TI"GRuby 1.8, the method Enumerable#sort_by implements a ;TI"Dbuilt-in Schwartzian Transform, useful when key computation or ;TI"comparison is expensive.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"A%w(rhea kea flea).sort #=> ["flea", "kea", "rhea"]
;TI"I(1..10).sort { |a, b| b <=> a } #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Menum.sort -> array
enum.sort { |a, b| block } -> array
;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #] inject-i.rinu [ U:RDoc::AnyMethod[iI"inject:ETI"Enumerable#inject;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"?Combines all elements of enum by applying a binary ;TI">operation, specified by a block or a symbol that names a ;TI"method or operator.;To:RDoc::Markup::BlankLine o;
; [I"BIf you specify a block, then for each element in enum ;TI"Mthe block is passed an accumulator value (memo) and the element. ;TI"JIf you specify a symbol instead, then each element in the collection ;TI"8will be passed to the named method of memo. ;TI"GIn either case, the result becomes the new value for memo. ;TI"HAt the end of the iteration, the final value of memo is the ;TI"!return value for the method.;T@o;
; [I"OIf you do not explicitly specify an initial value for memo, ;TI"Gthen the first element of collection is used as the initial value ;TI"of memo.;T@o:RDoc::Markup::Verbatim; [I"# Sum some numbers
;TI";(5..10).reduce(:+) #=> 45
;TI"%# Same using a block and inject
;TI";(5..10).inject { |sum, n| sum + n } #=> 45
;TI"# Multiply some numbers
;TI"?(5..10).reduce(1, :*) #=> 151200
;TI"# Same using a block
;TI"?(5..10).inject(1) { |product, n| product * n } #=> 151200
;TI"# find the longest word
;TI";longest = %w{ cat sheep bear }.inject do |memo, word|
;TI"0 memo.length > word.length ? memo : word
;TI" end
;TI"?longest #=> "sheep";T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"enum.inject(initial, sym) -> obj
enum.inject(sym) -> obj
enum.inject(initial) { |memo, obj| block } -> obj
enum.inject { |memo, obj| block } -> obj;T0[ I"(p1 = v1, p2 = v2);T@.FI"Enumerable;TcRDoc::NormalModule00PK #]+WD none%3f-i.rinu [ U:RDoc::AnyMethod[iI"
none?:ETI"Enumerable#none?;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"JPasses each element of the collection to the given block. The method ;TI"Lreturns true if the block never returns true ;TI"Qfor all elements. If the block is not given, none? will return ;TI"Ftrue only if none of the collection members is true.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [
I"A%w{ant bear cat}.none? { |word| word.length == 5 } #=> true
;TI"B%w{ant bear cat}.none? { |word| word.length >= 4 } #=> false
;TI"A[].none? #=> true
;TI"A[nil].none? #=> true
;TI"@[nil, false].none? #=> true;T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"5enum.none? [{ |obj| block }] -> true or false
;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #]NE min_by-i.rinu [ U:RDoc::AnyMethod[iI"min_by:ETI"Enumerable#min_by;TF:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [I">Returns the object in enum that gives the minimum ;TI" value from the given block.;To:RDoc::Markup::BlankLine o;
; [I"=If no block is given, an enumerator is returned instead.;T@o:RDoc::Markup::Verbatim; [I"!a = %w(albatross dog horse)
;TI"*a.min_by { |x| x.length } #=> "dog";T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Uenum.min_by { |obj| block } -> obj
enum.min_by -> an_enumerator
;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #] k each_with_object-i.rinu [ U:RDoc::AnyMethod[iI"each_with_object:ETI" Enumerable#each_with_object;TF:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [I"AIterates the given block for each element with an arbitrary ;TI":object given, and returns the initially given object.;To:RDoc::Markup::BlankLine o;
; [I"1If no block is given, returns an enumerator.;T@o:RDoc::Markup::Verbatim; [I">evens = (1..10).each_with_object([]) { |i, a| a << i*2 }
;TI"-#=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"enum.each_with_object(obj) { |(*args), memo_obj| ... } -> obj
enum.each_with_object(obj) -> an_enumerator
;T0[ I" (p1);T@FI"Enumerable;TcRDoc::NormalModule00PK #]k b b cdesc-Enumerable.rinu [ U:RDoc::NormalModule[iI"Enumerable:ET@0o:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[
I"HThe Enumerable mixin provides collection classes with ;TI"Fseveral traversal and searching methods, and with the ability to ;TI"Dsort. The class must provide a method each, which ;TI"5yields successive members of the collection. If ;TI"8Enumerable#max, #min, or ;TI"I#sort is used, the objects in the collection must also ;TI"Himplement a meaningful <=> operator, as these methods ;TI";rely on an ordering between members of the collection.;T:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0o;;[ ;
I"lib/set.rb;T;0;
0;0[ [ [ [[I"
class;T[[:public[ [:protected[ [:private[ [I"
instance;T[[;[7[I" all?;TI"enum.c;T[I" any?;T@.[I"
chunk;T@.[I"collect;T@.[I"collect_concat;T@.[I"
count;T@.[I"
cycle;T@.[I"detect;T@.[I" drop;T@.[I"drop_while;T@.[I"each_cons;T@.[I"each_entry;T@.[I"each_slice;T@.[I"each_with_index;T@.[I"each_with_object;T@.[I"entries;T@.[I" find;T@.[I"
find_all;T@.[I"find_index;T@.[I"
first;T@.[I"
flat_map;T@.[I" grep;T@.[I"
group_by;T@.[I"
include?;T@.[I"inject;T@.[I" lazy;TI"enumerator.c;T[I"map;T@.[I"max;T@.[I"max_by;T@.[I"member?;T@.[I"min;T@.[I"min_by;T@.[I"minmax;T@.[I"minmax_by;T@.[I"
none?;T@.[I" one?;T@.[I"partition;T@.[I"reduce;T@.[I"reject;T@.[I"reverse_each;T@.[I"select;T@.[I"slice_before;T@.[I" sort;T@.[I"sort_by;T@.[I" take;T@.[I"take_while;T@.[I" to_a;T@.[I" to_h;T@.[I"to_set;FI"lib/set.rb;T[I"zip;T@.[;
[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;
0;0[@I"enumerator.c;T@@cRDoc::TopLevelPK #]
l l include%3f-i.rinu [ U:RDoc::AnyMethod[iI"
include?:ETI"Enumerable#include?;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"CReturns true if any member of enum equals ;TI":obj. Equality is tested using ==.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"7IO.constants.include? :SEEK_SET #=> true
;TI"7IO.constants.include? :SEEK_NO_FURTHER #=> false;T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I",enum.include?(obj) -> true or false;T0[ I" (p1);T@FI"Enumerable;TcRDoc::NormalModule00PK #]ּ%v v filter_map-i.rinu [ U:RDoc::AnyMethod[iI"filter_map:ETI"Enumerable#filter_map;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"GReturns an array containing truthy elements returned by the block.;To:RDoc::Markup::BlankLine o;
; [I"CWith a block given, calls the block with successive elements; ;TI"Ireturns an array containing each truthy value returned by the block:;T@o:RDoc::Markup::Verbatim; [I"c(0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16]
;TI"^{foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz]
;T:@format0o;
; [I"1When no block given, returns an \Enumerator.;T:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Cfilter_map {|element| ... } -> array
filter_map -> enumerator
;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #]s drop-i.rinu [ U:RDoc::AnyMethod[iI" drop:ETI"Enumerable#drop;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"HDrops first n elements from enum, and returns rest elements ;TI"in an array.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"a = [1, 2, 3, 4, 5, 0]
;TI"(a.drop(3) #=> [4, 5, 0];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I")enum.drop(n) -> array
;T0[ I" (p1);T@FI"Enumerable;TcRDoc::NormalModule00PK #]Ja{ collect-i.rinu [ U:RDoc::AnyMethod[iI"collect:ETI"Enumerable#collect;TF:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [I"IReturns a new array with the results of running block once ;TI"&for every element in enum.;To:RDoc::Markup::BlankLine o;
; [I"=If no block is given, an enumerator is returned instead.;T@o:RDoc::Markup::Verbatim; [I"3(1..4).map { |i| i*i } #=> [1, 4, 9, 16]
;TI"A(1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"];T:@format0:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Xenum.collect { |obj| block } -> array
enum.collect -> an_enumerator;T0[ I"();T@FI"Enumerable;TcRDoc::NormalModule00PK #]4]Q Q lazy-i.rinu [ U:RDoc::AnyMethod[iI" lazy:ETI"Enumerable#lazy;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I";Returns a lazy enumerator, whose methods map/collect, ;TI"Hflat_map/collect_concat, select/find_all, reject, grep, zip, take, ;TI"Btake_while, drop, and drop_while enumerate values only on an ;TI"Cas-needed basis. However, if a block is given to zip, values ;TI" are enumerated immediately.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading:
leveli: textI"Example;T@o;
; [I"5The following program finds pythagorean triples:;T@o:RDoc::Markup::Verbatim; [I"def pythagorean_triples
;TI"/ (1..Float::INFINITY).lazy.flat_map {|z|
;TI" (1..z).flat_map {|x|
;TI" (x..z).select {|y|
;TI"! x**2 + y**2 == z**2
;TI" }.map {|y|
;TI" [x, y, z]
;TI"
}
;TI" }
;TI" }
;TI" end
;TI"*# show first ten pythagorean triples
;TI"Mp pythagorean_triples.take(10).force # take is lazy, so force is needed
;TI";p pythagorean_triples.first(10) # first is eager
;TI".# show pythagorean triples less than 100
;TI">p pythagorean_triples.take_while { |*, z| z < 100 }.force;T:@format0:
@fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.lazy -> lazy_enumerator
;T0[ I"();T@*FI"Enumerable;TcRDoc::NormalModule00PK #]#M
tally-i.rinu [ U:RDoc::AnyMethod[iI"
tally:ETI"Enumerable#tally;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"