Sha256: 5732d904e82f8d14ad4800f74b08a8f392b720f9ca819dd99e044464156ff742

Contents?: true

Size: 311 Bytes

Versions: 12

Compression:

Stored size: 311 Bytes

Contents

#--
# Credit goes to Sean O'Halpin (ruby-talk:199877).
#++

module Enumerable

  # Cascade actions on each enumerated element.
  #
  # [9, 19, 29].cascade :succ, :to_s, :reverse
  # => ["01", "02", "03"]

  def cascade(*methods)
    methods.inject(self) { |ary, method| ary.map{ |x| x.send(method)}}
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
facets-1.4.5 lib/facets/core/enumerable/cascade.rb
facets-1.4.4 lib/facets/core/enumerable/cascade.rb
facets-1.7.0 lib/facets/core/enumerable/cascade.rb
facets-1.7.30 lib/facets/core/enumerable/cascade.rb
facets-1.7.38 lib/facets/core/enumerable/cascade.rb
facets-1.7.46 lib/facets/core/enumerable/cascade.rb
facets-1.8.0 lib/facets/core/enumerable/cascade.rb
facets-1.8.20 lib/facets/core/enumerable/cascade.rb
facets-1.8.49 lib/facets/core/enumerable/cascade.rb
facets-1.8.51 lib/facets/core/enumerable/cascade.rb
facets-1.8.54 lib/facets/core/enumerable/cascade.rb
facets-1.8.8 lib/facets/core/enumerable/cascade.rb