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(format: '%s: %s', **args) ⇒ String
Convert Hash to list.
-
#to_options ⇒ Object
Convert hash to command line options.
Instance Method Details
#to_list(format: '%s: %s', **args) ⇒ String
Convert Hash to list
For more examples see ‘fedux_org_stdlib/core_ext/array/list’
42 43 44 |
# File 'lib/fedux_org_stdlib/core_ext/hash/list.rb', line 42 def to_list(format: '%s: %s', **args) map { |key, value| format(format, key, value) }.to_list(**args) 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 |