Class: Lino::Model::Option
- Inherits:
-
Object
- Object
- Lino::Model::Option
- Defined in:
- lib/lino/model/option.rb
Instance Attribute Summary collapse
-
#option ⇒ Object
readonly
Returns the value of attribute option.
-
#placement ⇒ Object
readonly
Returns the value of attribute placement.
-
#quoting ⇒ Object
readonly
Returns the value of attribute quoting.
-
#separator ⇒ Object
readonly
Returns the value of attribute separator.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #array ⇒ Object (also: #to_a)
- #hash ⇒ Object
-
#initialize(option, value, opts = {}) ⇒ Option
constructor
A new instance of Option.
- #quoted_value ⇒ Object
- #string ⇒ Object (also: #to_s)
Constructor Details
#initialize(option, value, opts = {}) ⇒ Option
Returns a new instance of Option.
12 13 14 15 16 17 18 19 |
# File 'lib/lino/model/option.rb', line 12 def initialize(option, value, opts = {}) opts = with_defaults(opts) @option = option @value = value @separator = opts[:separator] @quoting = opts[:quoting] @placement = opts[:placement] end |
Instance Attribute Details
#option ⇒ Object (readonly)
Returns the value of attribute option.
6 7 8 |
# File 'lib/lino/model/option.rb', line 6 def option @option end |
#placement ⇒ Object (readonly)
Returns the value of attribute placement.
6 7 8 |
# File 'lib/lino/model/option.rb', line 6 def placement @placement end |
#quoting ⇒ Object (readonly)
Returns the value of attribute quoting.
6 7 8 |
# File 'lib/lino/model/option.rb', line 6 def quoting @quoting end |
#separator ⇒ Object (readonly)
Returns the value of attribute separator.
6 7 8 |
# File 'lib/lino/model/option.rb', line 6 def separator @separator end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/lino/model/option.rb', line 6 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
39 40 41 42 |
# File 'lib/lino/model/option.rb', line 39 def ==(other) self.class == other.class && state == other.state end |
#array ⇒ Object Also known as: to_a
30 31 32 33 34 35 36 |
# File 'lib/lino/model/option.rb', line 30 def array if separator == ' ' [option.to_s, value.to_s] else ["#{option}#{separator}#{value}"] end end |
#hash ⇒ Object
46 47 48 |
# File 'lib/lino/model/option.rb', line 46 def hash [self.class, state].hash end |
#quoted_value ⇒ Object
21 22 23 |
# File 'lib/lino/model/option.rb', line 21 def quoted_value "#{quoting}#{value}#{quoting}" end |
#string ⇒ Object Also known as: to_s
25 26 27 |
# File 'lib/lino/model/option.rb', line 25 def string "#{option}#{separator}#{quoted_value}" end |