Class: Pdi::Spoon::Options::Arg
- Inherits:
-
Object
- Object
- Pdi::Spoon::Options::Arg
- Defined in:
- lib/pdi/spoon/options/arg.rb
Overview
This class can form Pentaho-specific command-line arguments.
Direct Known Subclasses
Defined Under Namespace
Modules: Key
Constant Summary collapse
- COLON =
':'- DOUBLE_QUOTE =
'"'- EMPTY =
''- HYPHEN =
'-'- SPACE =
' '
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(key, value = '') ⇒ Arg
constructor
A new instance of Arg.
- #to_s ⇒ Object
Constructor Details
#initialize(key, value = '') ⇒ Arg
Returns a new instance of Arg.
32 33 34 35 36 37 38 39 |
# 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 |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
30 31 32 |
# File 'lib/pdi/spoon/options/arg.rb', line 30 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
30 31 32 |
# File 'lib/pdi/spoon/options/arg.rb', line 30 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
53 54 55 56 57 |
# File 'lib/pdi/spoon/options/arg.rb', line 53 def ==(other) other.instance_of?(self.class) && key == other.key && value == other.value end |
#hash ⇒ Object
49 50 51 |
# File 'lib/pdi/spoon/options/arg.rb', line 49 def hash [key, value].hash end |
#to_s ⇒ Object
41 42 43 44 45 46 47 |
# 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 |