Module: FunRuby::Enum
Overview
Module containing methods for enumerables
Class Method Summary collapse
-
.all?(function = F._, enumerable = F._) ⇒ Boolean
Returns a boolean which represents if all results of applying a function to each element are truthy.
-
.count(function = F._, enumerable = F._) ⇒ Integer
Goes through a given enumerable and count the amount of elements for which a passed function returned true.
-
.each(function = F._, enumerable = F._) ⇒ ::Array
Applies a function to each element of an enumerable and returns the initial enumerable.
-
.map(function = F._, enumerable = F._) ⇒ ::Array
Returns a new enumerable with new values calculated by applying a function to each element of a passed enumerable.
-
.reduce(function = F._, accumulator = F._, enumerable = F._) ⇒ Object
Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
-
.select(function = F._, enumerable = F._) ⇒ ::Array
Returns a new enumerable containing only these elements results of calling a function on them are truthy.
Instance Method Summary collapse
-
#all?(function = F._, enumerable = F._) ⇒ Boolean
Returns a boolean which represents if all results of applying a function to each element are truthy.
-
#count(function = F._, enumerable = F._) ⇒ Integer
Goes through a given enumerable and count the amount of elements for which a passed function returned true.
-
#each(function = F._, enumerable = F._) ⇒ ::Array
Applies a function to each element of an enumerable and returns the initial enumerable.
-
#map(function = F._, enumerable = F._) ⇒ ::Array
Returns a new enumerable with new values calculated by applying a function to each element of a passed enumerable.
-
#reduce(function = F._, accumulator = F._, enumerable = F._) ⇒ Object
Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
-
#select(function = F._, enumerable = F._) ⇒ ::Array
Returns a new enumerable containing only these elements results of calling a function on them are truthy.
Class Method Details
.all?(function = F._, enumerable = F._) ⇒ Boolean
Returns a boolean which represents if all results of applying a function to each element are truthy
35 36 37 |
# File 'lib/fun_ruby/enum.rb', line 35 def all?(function = F._, enumerable = F._) curry_implementation(:all?, function, enumerable) end |
.count(function = F._, enumerable = F._) ⇒ Integer
Goes through a given enumerable and count the amount of elements for which a passed function returned true
180 181 182 |
# File 'lib/fun_ruby/enum.rb', line 180 def count(function = F._, enumerable = F._) curry_implementation(:count, function, enumerable) end |
.each(function = F._, enumerable = F._) ⇒ ::Array
Applies a function to each element of an enumerable and returns the initial enumerable
59 60 61 |
# File 'lib/fun_ruby/enum.rb', line 59 def each(function = F._, enumerable = F._) curry_implementation(:each, function, enumerable) end |
.map(function = F._, enumerable = F._) ⇒ ::Array
Returns a new enumerable with new values calculated by applying a function to each element of a passed enumerable
83 84 85 |
# File 'lib/fun_ruby/enum.rb', line 83 def map(function = F._, enumerable = F._) curry_implementation(:map, function, enumerable) end |
.reduce(function = F._, accumulator = F._, enumerable = F._) ⇒ Object
Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
153 154 155 |
# File 'lib/fun_ruby/enum.rb', line 153 def reduce(function = F._, accumulator = F._, enumerable = F._) curry_implementation(:reduce, function, accumulator, enumerable) end |
.select(function = F._, enumerable = F._) ⇒ ::Array
Returns a new enumerable containing only these elements results of calling a function on them are truthy
107 108 109 |
# File 'lib/fun_ruby/enum.rb', line 107 def select(function = F._, enumerable = F._) curry_implementation(:select, function, enumerable) end |
Instance Method Details
#all?(function = F._, enumerable = F._) ⇒ Boolean
Returns a boolean which represents if all results of applying a function to each element are truthy
35 36 37 |
# File 'lib/fun_ruby/enum.rb', line 35 def all?(function = F._, enumerable = F._) curry_implementation(:all?, function, enumerable) end |
#count(function = F._, enumerable = F._) ⇒ Integer
Goes through a given enumerable and count the amount of elements for which a passed function returned true
180 181 182 |
# File 'lib/fun_ruby/enum.rb', line 180 def count(function = F._, enumerable = F._) curry_implementation(:count, function, enumerable) end |
#each(function = F._, enumerable = F._) ⇒ ::Array
Applies a function to each element of an enumerable and returns the initial enumerable
59 60 61 |
# File 'lib/fun_ruby/enum.rb', line 59 def each(function = F._, enumerable = F._) curry_implementation(:each, function, enumerable) end |
#map(function = F._, enumerable = F._) ⇒ ::Array
Returns a new enumerable with new values calculated by applying a function to each element of a passed enumerable
83 84 85 |
# File 'lib/fun_ruby/enum.rb', line 83 def map(function = F._, enumerable = F._) curry_implementation(:map, function, enumerable) end |
#reduce(function = F._, accumulator = F._, enumerable = F._) ⇒ Object
Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
153 154 155 |
# File 'lib/fun_ruby/enum.rb', line 153 def reduce(function = F._, accumulator = F._, enumerable = F._) curry_implementation(:reduce, function, accumulator, enumerable) end |
#select(function = F._, enumerable = F._) ⇒ ::Array
Returns a new enumerable containing only these elements results of calling a function on them are truthy
107 108 109 |
# File 'lib/fun_ruby/enum.rb', line 107 def select(function = F._, enumerable = F._) curry_implementation(:select, function, enumerable) end |