Class: Gobstones::Runner::ProgramExecutionContext
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#clear, for_program, #get, #has_variable_named?, #set
Constructor Details
Returns a new instance of ProgramExecutionContext.
50
51
52
53
54
|
# File 'lib/gobstones/runner/execution_context.rb', line 50
def initialize(program)
super()
@head = Head.new
@program = program
end
|
Instance Attribute Details
#head ⇒ Object
Returns the value of attribute head.
44
45
46
|
# File 'lib/gobstones/runner/execution_context.rb', line 44
def head
@head
end
|
Class Method Details
.for(program) ⇒ Object
46
47
48
|
# File 'lib/gobstones/runner/execution_context.rb', line 46
def self.for(program)
new(program)
end
|
Instance Method Details
#board ⇒ Object
66
67
68
|
# File 'lib/gobstones/runner/execution_context.rb', line 66
def board
head.board
end
|
#definition_named(name, found_block, not_found_block) ⇒ Object
56
57
58
59
60
|
# File 'lib/gobstones/runner/execution_context.rb', line 56
def definition_named(name, found_block, not_found_block)
if_none = proc { return not_found_block.call }
found_definition = @program.definitions.detect(if_none) { |definition| definition.named?(name) }
found_block.call(found_definition)
end
|
#program_context ⇒ Object
62
63
64
|
# File 'lib/gobstones/runner/execution_context.rb', line 62
def program_context
self
end
|