Class: DTRCore::Instruction

Inherits:
Object
  • Object
show all
Defined in:
lib/dtr_core/instruction.rb

Overview

Instruction class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instruction, inputs, assign, scope) ⇒ Instruction

Returns a new instance of Instruction.



8
9
10
11
12
13
# File 'lib/dtr_core/instruction.rb', line 8

def initialize(instruction, inputs, assign, scope)
  @instruction = instruction
  @inputs = inputs
  @assign = assign
  @scope = scope
end

Instance Attribute Details

#assignObject (readonly)

Returns the value of attribute assign.



6
7
8
# File 'lib/dtr_core/instruction.rb', line 6

def assign
  @assign
end

#inputsObject (readonly)

Returns the value of attribute inputs.



6
7
8
# File 'lib/dtr_core/instruction.rb', line 6

def inputs
  @inputs
end

#instructionObject (readonly)

Returns the value of attribute instruction.



6
7
8
# File 'lib/dtr_core/instruction.rb', line 6

def instruction
  @instruction
end

#scopeObject (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



15
16
17
18
19
20
# File 'lib/dtr_core/instruction.rb', line 15

def ==(other)
  instruction == other.instruction &&
    inputs == other.inputs &&
    assign == other.assign &&
    scope == other.scope
end

#to_json(*_args) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/dtr_core/instruction.rb', line 28

def to_json(*_args)
  {
    instruction:,
    inputs:,
    assign:,
    scope:
  }.to_json
end

#to_sObject



22
23
24
25
26
# File 'lib/dtr_core/instruction.rb', line 22

def to_s
  "{ instruction: #{instruction}, " \
    "input: (#{inputs&.join(', ')}), " \
    "assign: #{assign}, scope: #{scope} }"
end

#valid?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/dtr_core/instruction.rb', line 37

def valid?
  DTRCore::InstructionValidator.new(self).valid?
end