Class: Propro::Option
- Inherits:
-
Object
- Object
- Propro::Option
- Defined in:
- lib/propro/option.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(key, value, opts = {}) ⇒ Option
constructor
A new instance of Option.
- #to_bash ⇒ Object
- #value ⇒ Object
- #value=(val) ⇒ Object
Constructor Details
#initialize(key, value, opts = {}) ⇒ Option
Returns a new instance of Option.
5 6 7 8 9 |
# File 'lib/propro/option.rb', line 5 def initialize(key, value, opts = {}) @key = key.to_s.downcase.to_sym @value = value @is_literal = opts[:lit] ? true : false end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/propro/option.rb', line 3 def name @name end |
Instance Method Details
#to_bash ⇒ Object
32 33 34 |
# File 'lib/propro/option.rb', line 32 def to_bash "#{name}=#{value}" end |
#value ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/propro/option.rb', line 19 def value case @value when Array %{"#{@value.join(' ')}"} when true %{"yes"} when false %{"no"} else @is_literal ? %{'#{@value}'} : %{"#{@value}"} end end |
#value=(val) ⇒ Object
15 16 17 |
# File 'lib/propro/option.rb', line 15 def value=(val) @value = val end |