Sha256: 7acbcedbe37bae9d623830fb5be194bd12b0fdf1218db975863fc487c89ec6b4

Contents?: true

Size: 474 Bytes

Versions: 3

Compression:

Stored size: 474 Bytes

Contents

# pops the top 2 items of the +:bool+ stack;
# pushes a ValuePoint with their logical OR onto the +:bool+ stack
#
# *needs:* 2 +:bool+
#
# *pushes:* 1 +:bool+
#

class BoolOrInstruction < Instruction
  
  def preconditions?
    needs :bool, 2
  end
  
  def setup
    @arg1 = @context.pop_value(:bool)
    @arg2 = @context.pop_value(:bool)
  end
  
  def derive
    @result = ValuePoint.new("bool", @arg1 || @arg2)
  end
  
  def cleanup
    pushes :bool, @result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nudge-0.2.9 lib/instructions/bool/bool_or.rb
nudge-0.2.8 lib/instructions/bool/bool_or.rb
nudge-0.2.7 lib/instructions/bool/bool_or.rb