Class: CodeListInstruction
- Inherits:
-
Instruction
- Object
- Instruction
- CodeListInstruction
- Defined in:
- lib/instructions/code/code_list.rb
Overview
pops the top 2 items from the :code
stack; pushes a new :code
item containing a block obtained by combining the other listings into one block
note: the top stack item (the “attachment”) is the second item of the resulting list
needs: 2 :code
pushes: 1 :code
Instance Attribute Summary
Attributes inherited from Instruction
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
26 27 28 |
# File 'lib/instructions/code/code_list.rb', line 26 def cleanup pushes :code, @result end |
#derive ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/instructions/code/code_list.rb', line 19 def derive listed = [] listed << NudgeProgram.new(@arg1).linked_code unless @arg1 == "" listed << NudgeProgram.new(@arg2).linked_code unless @arg2 == "" combined = CodeblockPoint.new(listed).blueprint @result = ValuePoint.new("code", combined) end |
#preconditions? ⇒ Boolean
12 13 14 |
# File 'lib/instructions/code/code_list.rb', line 12 def preconditions? needs :code, 2 end |
#setup ⇒ Object
15 16 17 18 |
# File 'lib/instructions/code/code_list.rb', line 15 def setup @arg2 = @context.pop_value(:code) @arg1 = @context.pop_value(:code) end |