Class: BlocklyInterpreter::ExtensionBlocks::SwitchBlock::Conditional
- Inherits:
-
Object
- Object
- BlocklyInterpreter::ExtensionBlocks::SwitchBlock::Conditional
- Defined in:
- lib/blockly_interpreter/extension_blocks/switch_block.rb
Instance Attribute Summary collapse
-
#action_block ⇒ Object
readonly
Returns the value of attribute action_block.
-
#predicate_block ⇒ Object
readonly
Returns the value of attribute predicate_block.
Instance Method Summary collapse
- #execute_statement(execution_context) ⇒ Object
-
#initialize(switch_block, num) ⇒ Conditional
constructor
A new instance of Conditional.
- #matches?(value, execution_context) ⇒ Boolean
Constructor Details
#initialize(switch_block, num) ⇒ Conditional
Returns a new instance of Conditional.
8 9 10 11 |
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 8 def initialize(switch_block, num) @predicate_block = switch_block.values["CASE#{num}"] @action_block = switch_block.statements["DO#{num}"] end |
Instance Attribute Details
#action_block ⇒ Object (readonly)
Returns the value of attribute action_block.
6 7 8 |
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 6 def action_block @action_block end |
#predicate_block ⇒ Object (readonly)
Returns the value of attribute predicate_block.
6 7 8 |
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 6 def predicate_block @predicate_block end |
Instance Method Details
#execute_statement(execution_context) ⇒ Object
17 18 19 |
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 17 def execute_statement(execution_context) execution_context.execute(action_block) end |
#matches?(value, execution_context) ⇒ Boolean
13 14 15 |
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 13 def matches?(value, execution_context) predicate_block.value(execution_context) == value end |