class Pdi::Spoon::Options::Arg
This class can form Pentaho-specific command-line arguments.
Constants
- COLON
- DOUBLE_QUOTE
- EMPTY
- HYPHEN
- SPACE
Attributes
key[R]
value[R]
Public Class Methods
new(key, value = '')
click to toggle source
# File lib/pdi/spoon/options/arg.rb, line 32 def initialize(key, value = '') raise ArgumentError, 'key is required' if key.to_s.empty? @key = Key.const_get(key.to_s.upcase.to_sym) @value = value.to_s freeze end
Public Instance Methods
==(other)
click to toggle source
# File lib/pdi/spoon/options/arg.rb, line 53 def ==(other) other.instance_of?(self.class) && key == other.key && value == other.value end
Also aliased as: eql?
hash()
click to toggle source
# File lib/pdi/spoon/options/arg.rb, line 49 def hash [key, value].hash end
to_s()
click to toggle source
# File lib/pdi/spoon/options/arg.rb, line 41 def to_s separator = value.to_s.empty? ? EMPTY : COLON wrapper = wrap?(key, value) ? DOUBLE_QUOTE : EMPTY prefix = HYPHEN "#{wrapper}#{prefix}#{key}#{separator}#{value}#{wrapper}" end
Private Instance Methods
wrap?(key, value)
click to toggle source
# File lib/pdi/spoon/options/arg.rb, line 62 def wrap?(key, value) key.to_s.include?(SPACE) || value.to_s.include?(SPACE) end