Class: CodeInstructionsInstruction

Inherits:
Instruction show all
Defined in:
lib/instructions/code/code_instructions.rb

Overview

pushes a new :code item whose value is a block containing one call to every Instruction active in the context

note: the order of instructions is determined by the order they appear in the context’s library

needs: nothing

pushes: 1 :code

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

#cleanupObject



24
25
26
# File 'lib/instructions/code/code_instructions.rb', line 24

def cleanup
  pushes :code, @result
end

#deriveObject



18
19
20
21
22
# File 'lib/instructions/code/code_instructions.rb', line 18

def derive
  all_instructions = @context.instructions
  list_as_block = all_instructions.inject("block {") {|b,i| b + " do #{i.to_nudgecode}"} + "}"
  @result = ValuePoint.new("code", list_as_block)
end

#preconditions?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/instructions/code/code_instructions.rb', line 11

def preconditions?
  true
end

#setupObject



15
16
# File 'lib/instructions/code/code_instructions.rb', line 15

def setup
end