| Class | Array |
| In: |
lib/more/facets/random.rb
lib/more/facets/set.rb lib/more/facets/tuple.rb lib/more/facets/shellwords.rb |
| Parent: | Object |
Convert and array into a tuple.
# File lib/more/facets/set.rb, line 16
16: def power_set
17: if empty?
18: [self]
19: else
20: subset = dup
21: value = [ subset.pop ]
22: subsubs = subset.power_set
23: subsubs.concat( subsubs.map{ |subset| subset + value } )
24: end
25: end
Convert an array into command line parameters. The array is accepted in the format of Ruby method arguments —ie. [arg1, arg2, …, hash]
# File lib/more/facets/shellwords.rb, line 44
44: def to_shellwords
45: flags = (Hash===last ? pop : {})
46: flags = flags.to_shellwords
47: flags + ' ' + self #join(" ")
48: end