Class: BlocklyInterpreter::ExtensionBlocks::SwitchBlock::DSLMethods::SwitchBlockBuilder
- Inherits:
-
DSL::BlockBuilder
- Object
- DSL::BlockBuilder
- BlocklyInterpreter::ExtensionBlocks::SwitchBlock::DSLMethods::SwitchBlockBuilder
show all
- Defined in:
- lib/blockly_interpreter/extension_blocks/switch_block.rb
Instance Attribute Summary collapse
#block_type, #comment, #comment_pinned, #fields, #is_shadow, #mutation_attrs, #mutation_child_procs, #statements, #values, #x, #y
Instance Method Summary
collapse
#build_subblock, #comment_to_xml, #field, #field_to_xml, #mutation_attr, #mutation_child, #mutations_to_xml, #set_comment, #set_position!, #shadow!, #statement, #subblock_to_xml, #tag_name, #value
Constructor Details
Returns a new instance of SwitchBlockBuilder.
67
68
69
70
|
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 67
def initialize(block_type)
super
@predicate_number = 0
end
|
Instance Attribute Details
#predicate_number ⇒ Object
Returns the value of attribute predicate_number.
65
66
67
|
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 65
def predicate_number
@predicate_number
end
|
Instance Method Details
#action(&proc) ⇒ Object
85
86
87
88
|
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 85
def action(&proc)
statement "DO#{predicate_number}", &proc
@predicate_number += 1
end
|
#capture_as(var_name) ⇒ Object
72
73
74
75
|
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 72
def capture_as(var_name)
field "CAPTURE_VAR", var_name
mutation_attr('capture', 1)
end
|
#else_action(&proc) ⇒ Object
90
91
92
93
|
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 90
def else_action(&proc)
mutation_attr "else", 1
statement "ELSE", &proc
end
|
#predicate(&proc) ⇒ Object
81
82
83
|
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 81
def predicate(&proc)
value "CASE#{predicate_number}", &proc
end
|
#switch_value(&proc) ⇒ Object
77
78
79
|
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 77
def switch_value(&proc)
value "SWITCH_VAL", &proc
end
|
#to_xml(node) ⇒ Object
95
96
97
98
|
# File 'lib/blockly_interpreter/extension_blocks/switch_block.rb', line 95
def to_xml(node)
mutation_attr("case", @predicate_number) if @predicate_number > 0
super
end
|