Class: Lino::Model::Subcommand
- Inherits:
-
Object
- Object
- Lino::Model::Subcommand
- Defined in:
- lib/lino/model/subcommand.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#subcommand ⇒ Object
readonly
Returns the value of attribute subcommand.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #array ⇒ Object (also: #to_a)
- #hash ⇒ Object
-
#initialize(subcommand, opts = {}) ⇒ Subcommand
constructor
A new instance of Subcommand.
- #string ⇒ Object (also: #to_s)
Constructor Details
#initialize(subcommand, opts = {}) ⇒ Subcommand
Returns a new instance of Subcommand.
8 9 10 11 12 |
# File 'lib/lino/model/subcommand.rb', line 8 def initialize(subcommand, opts = {}) opts = with_defaults(opts) @subcommand = subcommand = Hamster::Vector.new(opts[:options]) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/lino/model/subcommand.rb', line 6 def end |
#subcommand ⇒ Object (readonly)
Returns the value of attribute subcommand.
6 7 8 |
# File 'lib/lino/model/subcommand.rb', line 6 def subcommand @subcommand end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
24 25 26 27 |
# File 'lib/lino/model/subcommand.rb', line 24 def ==(other) self.class == other.class && state == other.state end |
#array ⇒ Object Also known as: to_a
19 20 21 |
# File 'lib/lino/model/subcommand.rb', line 19 def array [@subcommand.to_s, .map(&:array)].flatten end |
#hash ⇒ Object
30 31 32 |
# File 'lib/lino/model/subcommand.rb', line 30 def hash [self.class, state].hash end |
#string ⇒ Object Also known as: to_s
14 15 16 |
# File 'lib/lino/model/subcommand.rb', line 14 def string [@subcommand.to_s, .map(&:string)].reject(&:empty?).join(' ') end |