Class: CTioga2::Commands::Instruction
- Inherits:
-
Object
- Object
- CTioga2::Commands::Instruction
- Defined in:
- lib/ctioga2/commands/instruction.rb
Overview
This class represents an instruction, i.e. the execution of one Command. It is different in Command in that, for most of them, there will be arguments
Instance Attribute Summary collapse
-
#arguments ⇒ Object
The list of its arguments, already in the correct type.
-
#command ⇒ Object
The Command.
-
#options ⇒ Object
The options, already in the correct type.
Instance Method Summary collapse
-
#initialize(cmd, args, opts) ⇒ Instruction
constructor
A new instance of Instruction.
-
#run(plotmaker_target) ⇒ Object
Runs this instruction again.
- #to_s ⇒ Object
Constructor Details
#initialize(cmd, args, opts) ⇒ Instruction
Returns a new instance of Instruction.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ctioga2/commands/instruction.rb', line 37 def initialize(cmd, args, opts) if not cmd.respond_to?(:run_command) c = Interpreter.command(cmd) if ! c raise "Invalid command #{cmd}" end cmd = c end @command = cmd @arguments = args @options = opts end |
Instance Attribute Details
#arguments ⇒ Object
The list of its arguments, already in the correct type.
32 33 34 |
# File 'lib/ctioga2/commands/instruction.rb', line 32 def arguments @arguments end |
#command ⇒ Object
The Command
29 30 31 |
# File 'lib/ctioga2/commands/instruction.rb', line 29 def command @command end |
#options ⇒ Object
The options, already in the correct type
35 36 37 |
# File 'lib/ctioga2/commands/instruction.rb', line 35 def @options end |
Instance Method Details
#run(plotmaker_target) ⇒ Object
Runs this instruction again
51 52 53 |
# File 'lib/ctioga2/commands/instruction.rb', line 51 def run(plotmaker_target) @command.run_command(plotmaker_target, @arguments, @options) end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/ctioga2/commands/instruction.rb', line 55 def to_s "#{@command.name} #{@arguments.inspect} #{@options.inspect}" end |