Class: BlocklyInterpreter::CoreBlocks::ListsCreateWithBlock::DSLMethods::ListsCreateWithBlockBuilder

Inherits:
DSL::BlockBuilder
  • Object
show all
Defined in:
lib/blockly_interpreter/core_blocks/lists_create_with_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) ⇒ ListsCreateWithBlockBuilder

Returns a new instance of ListsCreateWithBlockBuilder.



26
27
28
29
# File 'lib/blockly_interpreter/core_blocks/lists_create_with_block.rb', line 26

def initialize(block_type)
  super
  @item_number = 0
end

Instance Method Details

#item(&proc) ⇒ Object



31
32
33
34
# File 'lib/blockly_interpreter/core_blocks/lists_create_with_block.rb', line 31

def item(&proc)
  value("ADD#{@item_number}", &proc)
  @item_number += 1
end

#to_xml(node) ⇒ Object



36
37
38
39
# File 'lib/blockly_interpreter/core_blocks/lists_create_with_block.rb', line 36

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