Class: BlocklyInterpreter::CoreBlocks::ProcedureBlock::DSLMethods::ProcedureCallBlockBuilder

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

Instance Attribute Summary collapse

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, #to_xml, #value

Constructor Details

#initialize(block_type, procedure_name) ⇒ ProcedureCallBlockBuilder

Returns a new instance of ProcedureCallBlockBuilder.



32
33
34
35
36
37
# File 'lib/blockly_interpreter/core_blocks/procedure_block.rb', line 32

def initialize(block_type, procedure_name)
  super(block_type)

  mutation_attr :name, procedure_name
  @arg_number = 0
end

Instance Attribute Details

#arg_numberObject (readonly)

Returns the value of attribute arg_number.



30
31
32
# File 'lib/blockly_interpreter/core_blocks/procedure_block.rb', line 30

def arg_number
  @arg_number
end

Instance Method Details

#arg(name, &proc) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/blockly_interpreter/core_blocks/procedure_block.rb', line 39

def arg(name, &proc)
  mutation_child :arg do |child|
    child['name'] = name
  end

  value "ARG#{arg_number}", &proc
  @arg_number += 1
end