Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/fedux_org_stdlib/core_ext/hash/list.rb,
lib/fedux_org_stdlib/core_ext/hash/options.rb
Instance Method Summary collapse
- #to_list ⇒ Object
-
#to_options ⇒ Object
Convert hash to command line options.
Instance Method Details
#to_list ⇒ Object
5 6 7 |
# File 'lib/fedux_org_stdlib/core_ext/hash/list.rb', line 5 def to_list self.map { |key, value| format('%s: %s', key, value) }.to_list end |
#to_options ⇒ Object
Convert hash to command line options
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fedux_org_stdlib/core_ext/hash/options.rb', line 52 def each_with_object([]) do |(key, value), a| key = Shellwords.clean(key) if value.is_a? TrueClass a << "--#{key}" elsif value.is_a? FalseClass a << "--no-#{key}" else a << "--#{key}" a << Shellwords.escape(value) end end end |