Class: CodeContainerInstruction
Instance Attribute Summary
Attributes inherited from Instruction
#context
Instance Method Summary
collapse
Methods inherited from Instruction
all_instructions, #go, inherited, #initialize, #needs, #pushes, to_nudgecode
Constructor Details
This class inherits a constructor from Instruction
Instance Method Details
#cleanup ⇒ Object
25
26
27
|
# File 'lib/instructions/code/code_container.rb', line 25
def cleanup
pushes :code, @result
end
|
#derive ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/instructions/code/code_container.rb', line 12
def derive
needle = NudgeProgram.new(@searching_for_this).linked_code.blueprint
haystack_program = NudgeProgram.new(@searching_in_this)
haystack = haystack_program.linked_code
if needle == haystack.blueprint
result_value = "block {}"
else
where = haystack.find_index {|point| point.blueprint == needle}
result_value = where.nil? ? "block {}" : haystack_program[where].blueprint
end
@result = ValuePoint.new("code", result_value)
end
|
#preconditions? ⇒ Boolean
5
6
7
|
# File 'lib/instructions/code/code_container.rb', line 5
def preconditions?
needs :code, 2
end
|
#setup ⇒ Object
8
9
10
11
|
# File 'lib/instructions/code/code_container.rb', line 8
def setup
@searching_in_this = @context.pop_value(:code)
@searching_for_this = @context.pop_value(:code)
end
|