Class: Lino::Model::CommandLine
- Inherits:
-
Object
- Object
- Lino::Model::CommandLine
- Defined in:
- lib/lino/model/command_line.rb
Constant Summary collapse
- COMPONENTS =
[ i[environment_variables], i[command], i[ after_command], i[subcommands], i[ after_subcommands], i[arguments], i[ after_arguments] ].freeze
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#environment_variables ⇒ Object
readonly
Returns the value of attribute environment_variables.
-
#executor ⇒ Object
readonly
Returns the value of attribute executor.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#subcommands ⇒ Object
readonly
Returns the value of attribute subcommands.
-
#working_directory ⇒ Object
readonly
Returns the value of attribute working_directory.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #array ⇒ Object (also: #to_a)
- #env ⇒ Object
- #execute(opts = {}) ⇒ Object
- #hash ⇒ Object
-
#initialize(command, opts = {}) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #string ⇒ Object (also: #to_s)
Constructor Details
#initialize(command, opts = {}) ⇒ CommandLine
Returns a new instance of CommandLine.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lino/model/command_line.rb', line 24 def initialize(command, opts = {}) opts = with_defaults(opts) @command = command @subcommands = Hamster::Vector.new(opts[:subcommands]) = Hamster::Vector.new(opts[:options]) @arguments = Hamster::Vector.new(opts[:arguments]) @environment_variables = Hamster::Vector.new(opts[:environment_variables]) @executor = opts[:executor] @working_directory = opts[:working_directory] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
16 17 18 |
# File 'lib/lino/model/command_line.rb', line 16 def arguments @arguments end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
16 17 18 |
# File 'lib/lino/model/command_line.rb', line 16 def command @command end |
#environment_variables ⇒ Object (readonly)
Returns the value of attribute environment_variables.
16 17 18 |
# File 'lib/lino/model/command_line.rb', line 16 def environment_variables @environment_variables end |
#executor ⇒ Object (readonly)
Returns the value of attribute executor.
16 17 18 |
# File 'lib/lino/model/command_line.rb', line 16 def executor @executor end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/lino/model/command_line.rb', line 16 def end |
#subcommands ⇒ Object (readonly)
Returns the value of attribute subcommands.
16 17 18 |
# File 'lib/lino/model/command_line.rb', line 16 def subcommands @subcommands end |
#working_directory ⇒ Object (readonly)
Returns the value of attribute working_directory.
16 17 18 |
# File 'lib/lino/model/command_line.rb', line 16 def working_directory @working_directory end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
56 57 58 |
# File 'lib/lino/model/command_line.rb', line 56 def ==(other) self.class == other.class && state == other.state end |
#array ⇒ Object Also known as: to_a
44 45 46 |
# File 'lib/lino/model/command_line.rb', line 44 def array format_components(:array, COMPONENTS.drop(1)).flatten end |
#env ⇒ Object
40 41 42 |
# File 'lib/lino/model/command_line.rb', line 40 def env @environment_variables.to_h(&:array) end |
#execute(opts = {}) ⇒ Object
36 37 38 |
# File 'lib/lino/model/command_line.rb', line 36 def execute(opts = {}) @executor.execute(self, opts) end |
#hash ⇒ Object
62 63 64 |
# File 'lib/lino/model/command_line.rb', line 62 def hash [self.class, state].hash end |
#string ⇒ Object Also known as: to_s
50 51 52 |
# File 'lib/lino/model/command_line.rb', line 50 def string format_components(:string, COMPONENTS).join(' ') end |