Iteration is at the heart of idiomatic Ruby, and most collection methods are powered by the Enumerable module. The each method is the workhorse of iteration: it walks through a collection and yields each element to a block, returning the original collection unchanged. Methods like map, select, and reduce are layered on top of each, so any class that defines its own each method and includes Enumerable gains a powerful suite of operations.
The map method, also known by its alias collect, applies a block to every element and collects the results into a new array. For example, doubling a list produces [2, 4, 6] from the original [1, 2, 3]. The select method returns a new array containing only the elements for which the block returns a truthy value, making it ideal for filtering. The reduce method, aliased as inject, folds a collection into a single value by repeatedly applying a binary operation, starting from an optional initial accumulator. Combining these methods allows Ruby code to express transformations on data clearly and concisely without explicit loops.
Because Enumerable provides many additional methods such as sort, min, max, and find, defining an each method on a custom class and including Enumerable is the standard way to make that class behave like a first-class collection. This design reflects Ruby's philosophy: rather than building a large inheritance hierarchy of collection types, the language provides a small set of core iteration primitives and composes them into a rich set of higher-level operations.