Class: DTRCore::InstructionValidator
- Inherits:
-
Object
- Object
- DTRCore::InstructionValidator
- Includes:
- Common
- Defined in:
- lib/dtr_core/instruction_validator.rb
Overview
Instruction validator for DTR types.
Instance Method Summary collapse
-
#initialize(instruction) ⇒ InstructionValidator
constructor
A new instance of InstructionValidator.
-
#valid? ⇒ Boolean
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength.
Methods included from Common
#capture_section, #clean_name, #split_strip_select
Constructor Details
#initialize(instruction) ⇒ InstructionValidator
Returns a new instance of InstructionValidator.
10 11 12 13 14 |
# File 'lib/dtr_core/instruction_validator.rb', line 10 def initialize(instruction) @instruction = instruction validate_input! end |
Instance Method Details
#valid? ⇒ Boolean
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dtr_core/instruction_validator.rb', line 18 def valid? return false unless scope_valid? case @instruction.instruction when 'assign', 'evaluate', 'print' validate_basic_operation! when 'exit_with_message', 'return' validate_terminating_operation! when 'and', 'or' validate_logical_operation! when 'goto', 'jump', 'end_of_iteration_check', 'label' validate_control_flow_operation! when 'field', 'instantiate_object' validate_object_operation! when 'add', 'subtract', 'multiply', 'divide' validate_binary_operation! when 'increment' true else false end end |