Class: BlocklyInterpreter::CoreBlocks::ComparisonOperatorBlock
- Defined in:
- lib/blockly_interpreter/core_blocks/comparison_operator_block.rb
Defined Under Namespace
Modules: DSLMethods
Instance Attribute Summary
Attributes inherited from Block
#block_type, #comment, #comment_pinned, #fields, #is_shadow, #mutation, #next_block, #statements, #values, #x, #y
Instance Method Summary collapse
Methods inherited from Block
#each_block, #execute_statement, #has_comment?, #has_position?, #initialize, #to_xml, #to_xml_element
Constructor Details
This class inherits a constructor from BlocklyInterpreter::Block
Instance Method Details
#to_dsl ⇒ Object
24 25 26 |
# File 'lib/blockly_interpreter/core_blocks/comparison_operator_block.rb', line 24 def to_dsl BlocklyInterpreter::DSL::BinaryOperationDSLGenerator.new(self, "logic_compare").dsl end |
#value(execution_context) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/blockly_interpreter/core_blocks/comparison_operator_block.rb', line 4 def value(execution_context) a = values['A'].value(execution_context) b = values['B'].value(execution_context) a, b = cast_values(a, b) begin case fields['OP'] when 'EQ' then a == b when 'NEQ' then a != b when 'LT' then a < b when 'GT' then a > b when 'LTE' then a <= b when 'GTE' then a >= b end rescue false end end |