Class: BlocklyInterpreter::CoreBlocks::ListsGetIndexBlock::DSLMethods::ListsGetIndexBlockBuilder

Inherits:
DSL::BlockBuilder
  • Object
show all
Defined in:
lib/blockly_interpreter/core_blocks/lists_get_index_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, #initialize, #mutation_attr, #mutation_child, #mutations_to_xml, #set_comment, #set_position!, #shadow!, #statement, #subblock_to_xml, #tag_name, #value

Constructor Details

This class inherits a constructor from BlocklyInterpreter::DSL::BlockBuilder

Instance Method Details

#at(index = nil, &proc) ⇒ Object



41
42
43
44
45
# File 'lib/blockly_interpreter/core_blocks/lists_get_index_block.rb', line 41

def at(index = nil, &proc)
  proc ||= Proc.new { math_number index }
  @has_at = true
  value 'AT', &proc
end

#list(&proc) ⇒ Object



47
48
49
# File 'lib/blockly_interpreter/core_blocks/lists_get_index_block.rb', line 47

def list(&proc)
  value 'VALUE', &proc
end

#to_xml(node) ⇒ Object



51
52
53
54
55
# File 'lib/blockly_interpreter/core_blocks/lists_get_index_block.rb', line 51

def to_xml(node)
  mutation_attr('statement', (@fields["MODE"] == 'REMOVE').to_s)
  mutation_attr('at', (!!@has_at).to_s)
  super
end