Module Denumerable
In: lib/core/facets/denumerable.rb

Denumerable

Classes which include Enumerable::Filterable will get versions of map, select etc. which return a Filter, so that they work horizontally without creating intermediate arrays.

Methods

collect   find_all   map   reject   select   skip   take  

Public Instance methods

collect()

Alias for map

find_all()

Alias for select

[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

[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

[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

Skip the first n items in the list

[Source]

    # 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

Limit to the first n items in the list

[Source]

    # 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

[Validate]