Sha256: 56a1d135a45cfc07a1bd26cbf7d8ef9793086d181976de96eb4d4b1ca1d93c90

Contents?: true

Size: 621 Bytes

Versions: 3

Compression:

Stored size: 621 Bytes

Contents

class BlocklyInterpreter::CoreBlocks::SetVariableBlock < BlocklyInterpreter::Block
  include BlocklyInterpreter::DSLGenerator

  self.block_type = :variables_set

  def execute_statement(execution_context)
    execution_context.set_variable(fields['VAR'], values['VALUE'].value(execution_context))
  end

  def to_dsl
    method_call_with_possible_block("variables_set", fields['VAR'].inspect, values['VALUE'])
  end

  module DSLMethods
    def variables_set(name, &proc)
      block :variables_set do
        field :VAR, name
        value :VALUE do
          instance_exec &proc
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blockly_interpreter-0.3.0 lib/blockly_interpreter/core_blocks/set_variable_block.rb
blockly_interpreter-0.2.1 lib/blockly_interpreter/core_blocks/set_variable_block.rb
blockly_interpreter-0.2.0 lib/blockly_interpreter/core_blocks/set_variable_block.rb