Denumerable

Denumerable

Classes which include Denumerable will get versions of map, select, and so on, which return a Denumerator, so that they work horizontally without creating intermediate arrays.

Public Instance Methods

collect() click to toggle source
Alias for: map
find_all() click to toggle source
Alias for: select
map() click to toggle source
    # File lib/core/facets/denumerable.rb, line 13
13:   def map
14:     Denumerator.new do |output|
15:       each do |*input|
16:         output.yield yield(*input)
17:       end
18:     end
19:   end
Also aliased as: collect
reject() click to toggle source
    # File lib/core/facets/denumerable.rb, line 33
33:   def reject
34:     Denumerator.new do |output|
35:       each do |*input|
36:         output.yield(*input) unless yield(*input)
37:       end
38:     end
39:   end
select() click to toggle source
    # File lib/core/facets/denumerable.rb, line 23
23:   def select
24:     Denumerator.new do |output|
25:       each do |*input|
26:         output.yield(*input) if yield(*input)
27:       end
28:     end
29:   end
Also aliased as: find_all
skip(n) click to toggle source

Skip the first n items in the list

    # File lib/core/facets/denumerable.rb, line 54
54:   def skip(n)
55:     Denumerator.new do |output|
56:       count = 0
57:       each do |*input|
58:         output.yield(*input) if count >= n
59:         count += 1
60:       end
61:     end
62:   end
take(n) click to toggle source

Limit to the first n items in the list

    # File lib/core/facets/denumerable.rb, line 42
42:   def take(n)
43:     Denumerator.new do |output|
44:       count = 0
45:       each do |*input|
46:         break if count >= n
47:         output.yield(*input)
48:         count += 1
49:       end
50:     end
51:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.