Class: Array
- Extended by:
- Filigree::Destructurable
- Defined in:
- lib/filigree/array.rb,
lib/filigree/match.rb
Overview
Standard Library Deconstructors #
Instance Method Summary collapse
- #aliased_map ⇒ Object
-
#destructure(num_elems) ⇒ Array<Object>
Destructuring for the array class.
-
#map(method = nil, &block) ⇒ Array<Object>
Map now takes an optional symbol argument.
Methods included from Filigree::Destructurable
Instance Method Details
#aliased_map ⇒ Object
19 |
# File 'lib/filigree/array.rb', line 19 alias :aliased_map :map |
#destructure(num_elems) ⇒ Array<Object>
Destructuring for the array class. If the array is being matched against two patterns the destructuring of the array will be the first element and then an array containing the rest of the values. If there are three patterns the destructuring of the array will be the first and second elements, and then an array containing the remainder of the values.
487 488 489 |
# File 'lib/filigree/match.rb', line 487 def destructure(num_elems) [*self.first(num_elems - 1), self[(num_elems - 1)..-1]] end |
#map(method = nil, &block) ⇒ Array<Object>
Map now takes an optional symbol argument. If a symbol is provided the specified method is invoked on each of the objects in the array.
28 29 30 31 32 33 34 |
# File 'lib/filigree/array.rb', line 28 def map(method = nil, &block) if method self.aliased_map { |obj| obj.send(method) } else self.aliased_map(&block) end end |