File: cascade.rb

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (28 lines) | stat: -rw-r--r-- 802 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Enumerable

  #   # Cascade actions on each enumerated element.
  #   #
  #   #   [9, 19, 29].cascade :succ, :to_s, :reverse
  #   #   => ["01", "02", "03"]
  #   #
  #   # See ruby-talk:199877.
  #
  #   def cascade(*methods)
  #     methods.inject(self){ |ary, method| ary.map{ |x| x.send(method)}}
  #   end


  # DEPRECATED:
  #
  #   # Why the term counter? There may be a change in Ruby 2.0
  #   # to use this word instead of index. Index will
  #   # still be used for Array, since that is the proper meaning
  #   # in that context. In the mean time, aliases are provided.
  #
  #   alias_method( :collect_with_counter, :collect_with_index )
  #   alias_method( :map_with_counter, :collect_with_index )
  #
  #   #instance_map and #instance_select --too invasive for convenience.

end