core : enumerable

Enumerable is meant to be a squish-in. It provides some convenience methods to any object which implements each().
all?   any?   find   max   min   reject   select  

(boolean) all?

enum.all? block

Returns true if, for every object in the collection, the block returns true.

(boolean) any?

enum.any? block

Returns true if, for any object in the collection, the block returns true.

(boolean) find

enum.find block

Returns the first object for which the block returns true.

(boolean) max

enum.max

Returns maximum value in enumerable. All items in the enumerable must be comparable.

(boolean) min

enum.min

Returns minimum value in enumerable. All items in the enumerable must be comparable.

(array) reject

enum.reject block
enum.reject method_name

If passed a method name, invokes method on each element and returns an array containing any objects for which the method returns false. If passed a function, returns an array containing all objects for which the block returns false.

(array) select

enum.select block
enum.select method_name

If passed a method name, invokes method on each element and returns an array containing any objects for which the method returns true. If passed a function, returns an array containing all objects for which the block returns true.

Fork me on GitHub