Class: DTRCore::Instruction
- Inherits:
-
Object
- Object
- DTRCore::Instruction
- Defined in:
- lib/dtr_core/instruction.rb
Overview
Instruction class
Instance Attribute Summary collapse
-
#assign ⇒ Object
readonly
Returns the value of attribute assign.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#instruction ⇒ Object
readonly
Returns the value of attribute instruction.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(instruction, inputs, assign, scope, id) ⇒ Instruction
constructor
A new instance of Instruction.
- #to_json(*_args) ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(instruction, inputs, assign, scope, id) ⇒ Instruction
8 9 10 11 12 13 14 |
# File 'lib/dtr_core/instruction.rb', line 8 def initialize(instruction, inputs, assign, scope, id) @instruction = instruction @inputs = inputs @assign = assign @scope = scope @id = id end |
Instance Attribute Details
#assign ⇒ Object (readonly)
Returns the value of attribute assign.
6 7 8 |
# File 'lib/dtr_core/instruction.rb', line 6 def assign @assign end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/dtr_core/instruction.rb', line 6 def id @id end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
6 7 8 |
# File 'lib/dtr_core/instruction.rb', line 6 def inputs @inputs end |
#instruction ⇒ Object (readonly)
Returns the value of attribute instruction.
6 7 8 |
# File 'lib/dtr_core/instruction.rb', line 6 def instruction @instruction end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'lib/dtr_core/instruction.rb', line 6 def scope @scope end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/dtr_core/instruction.rb', line 16 def ==(other) instruction == other.instruction && inputs == other.inputs && assign == other.assign && scope == other.scope && id == other.id end |
#to_json(*_args) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/dtr_core/instruction.rb', line 31 def to_json(*_args) { instruction:, inputs:, assign:, scope:, id: }.to_json end |
#to_s ⇒ Object
24 25 26 27 28 29 |
# File 'lib/dtr_core/instruction.rb', line 24 def to_s assignment = @assign.nil? ? '' : "assign: #{@assign}, " "{ id: #{id}, instruction: #{instruction}, " \ "input: (#{inputs&.join(', ')}), " \ "#{assignment}scope: #{scope} }" end |
#valid? ⇒ Boolean
41 42 43 |
# File 'lib/dtr_core/instruction.rb', line 41 def valid? DTRCore::InstructionValidator.new(self).valid? end |