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
Overview
Hash
Instance Method Summary collapse
-
#to_list ⇒ String
Convert Hash to list.
-
#to_options ⇒ Object
Convert hash to command line options.
Instance Method Details
#to_list ⇒ String
Convert Hash to list
10 11 12 |
# File 'lib/fedux_org_stdlib/core_ext/hash/list.rb', line 10 def to_list map { |key, value| format('%s: %s', key, value) }.to_list end |
#to_options ⇒ Object
Convert hash to command line options
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fedux_org_stdlib/core_ext/hash/options.rb', line 53 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 |