Module: BlocklyInterpreter::CoreBlocks::ListsGetIndexBlock::DSLMethods

Defined in:
lib/blockly_interpreter/core_blocks/lists_get_index_block.rb

Defined Under Namespace

Classes: ListsGetIndexBlockBuilder

Instance Method Summary collapse

Instance Method Details

#lists_get_first(&proc) ⇒ Object



58
59
60
61
62
# File 'lib/blockly_interpreter/core_blocks/lists_get_index_block.rb', line 58

def lists_get_first(&proc)
  lists_get_index where: 'FIRST' do
    list &proc
  end
end

#lists_get_index(mode: 'GET', where: 'FROM_START', &proc) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/blockly_interpreter/core_blocks/lists_get_index_block.rb', line 76

def lists_get_index(mode: 'GET', where: 'FROM_START', &proc)
  @blocks << BlocklyInterpreter::CoreBlocks::ListsGetIndexBlock::DSLMethods::ListsGetIndexBlockBuilder.new("lists_getIndex").tap do |builder|
    builder.field 'MODE', mode
    builder.field 'WHERE', where
    builder.instance_exec(&proc)
  end
end

#lists_get_last(&proc) ⇒ Object



64
65
66
67
68
# File 'lib/blockly_interpreter/core_blocks/lists_get_index_block.rb', line 64

def lists_get_last(&proc)
  lists_get_index where: 'LAST' do
    list &proc
  end
end

#lists_get_random(&proc) ⇒ Object



70
71
72
73
74
# File 'lib/blockly_interpreter/core_blocks/lists_get_index_block.rb', line 70

def lists_get_random(&proc)
  lists_get_index where: 'RANDOM' do
    list &proc
  end
end