Class: HammerCLI::Options::Normalizers::List
- Inherits:
-
AbstractNormalizer
- Object
- AbstractNormalizer
- HammerCLI::Options::Normalizers::List
- Defined in:
- lib/hammer_cli/options/normalizers.rb
Instance Method Summary collapse
Methods inherited from AbstractNormalizer
Instance Method Details
#description ⇒ Object
97 98 99 100 |
# File 'lib/hammer_cli/options/normalizers.rb', line 97 def description _("Comma separated list of values. Values containing comma should be quoted or escaped with backslash.") + "\n" + _("JSON is acceptable and preferred way for complex parameters") end |
#format(val) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/hammer_cli/options/normalizers.rb', line 102 def format(val) return [] unless val.is_a?(String) && !val.empty? begin [JSON.parse(val)].flatten(1) rescue JSON::ParserError HammerCLI::CSVParser.new.parse(val) end end |