Class: BlocklyInterpreter::CoreBlocks::TextJoinBlock::DSLMethods::TextJoinBlockBuilder

Inherits:
DSL::BlockBuilder
  • Object
show all
Defined in:
lib/blockly_interpreter/core_blocks/text_join_block.rb

Instance Attribute Summary

Attributes inherited from DSL::BlockBuilder

#block_type, #comment, #comment_pinned, #fields, #is_shadow, #mutation_attrs, #mutation_child_procs, #statements, #values, #x, #y

Instance Method Summary collapse

Methods inherited from DSL::BlockBuilder

#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

#initialize(block_type) ⇒ TextJoinBlockBuilder

Returns a new instance of TextJoinBlockBuilder.



23
24
25
26
# File 'lib/blockly_interpreter/core_blocks/text_join_block.rb', line 23

def initialize(block_type)
  super
  @item_number = 0
end

Instance Method Details

#item(string = nil, &proc) ⇒ Object



28
29
30
31
32
# File 'lib/blockly_interpreter/core_blocks/text_join_block.rb', line 28

def item(string = nil, &proc)
  proc ||= Proc.new { text string }
  value("ADD#{@item_number}", &proc)
  @item_number += 1
end

#to_xml(node) ⇒ Object



34
35
36
37
# File 'lib/blockly_interpreter/core_blocks/text_join_block.rb', line 34

def to_xml(node)
  mutation_attr("items", @item_number)
  super
end