Fetching
Эти методы возвращают элементы из перечисляемого объекта, не изменяя его:
Leading, trailing, or all elements:
to_a(aliased asentries): Returns all elements.first: Returns the first element or leading elements.take: Returns a specified number of leading elements.drop: Returns a specified number of trailing elements.take_while: Returns leading elements as specified by the given block.drop_while: Returns trailing elements as specified by the given block.
Minimum and maximum value elements:
min: Returns the elements whose values are smallest among the elements, as determined by#<=>or a given block.max: Returns the elements whose values are largest among the elements, as determined by#<=>or a given block.minmax: Returns a 2-elementArraycontaining the smallest and largest elements.min_by: Returns the smallest element, as determined by the given block.max_by: Returns the largest element, as determined by the given block.minmax_by: Returns the smallest and largest elements, as determined by the given block.
Groups, slices, and partitions:
group_by: Returns aHashthat partitions the elements into groups.partition: Returns elements partitioned into two new Arrays, as determined by the given block.slice_after: Returns a newEnumeratorwhose entries are a partition ofself, based either on a givenobjector a given block.slice_before: Returns a newEnumeratorwhose entries are a partition ofself, based either on a givenobjector a given block.slice_when: Returns a newEnumeratorwhose entries are a partition ofselfbased on the given block.chunk: Returns elements organized into chunks as specified by the given block.chunk_while: Returns elements organized into chunks as specified by the given block.