Sha256: 2c1d0bc97069954de7b7c91d5b58ef41e449200fecbc8b2e6c14babae626829e

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 Bytes

Contents

# 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+
#

class CodeListInstruction < Instruction
  def preconditions?
    needs :code, 2
  end
  def setup
    @arg2 = @context.pop_value(:code)
    @arg1 = @context.pop_value(:code)
  end
  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
  def cleanup
    pushes :code, @result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nudge-0.2.9 lib/instructions/code/code_list.rb
nudge-0.2.8 lib/instructions/code/code_list.rb
nudge-0.2.7 lib/instructions/code/code_list.rb