Sha256: ce8af7075541a63fa2f9e2040a6c4504dbc7086565cc6d4dc5a4e25e0c2a0df8

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

# pops the top 2 items of the +:proportion+ stack;
# pushes a new ValuePoint onto the +:proportion+ stack with the smallest of the two values
#
# *needs:* 2 +:proportion+
#
# *pushes:* 1 +:proportion+
#

class ProportionMinInstruction < Instruction
  def preconditions?
    needs :proportion, 2
  end
  def setup
    @arg2 = @context.pop_value(:proportion)
    @arg1 = @context.pop_value(:proportion)
  end
  def derive
    @result = ValuePoint.new("proportion", [@arg1, @arg2].min)
  end
  def cleanup
    pushes :proportion, @result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nudge-0.2.9 lib/instructions/proportion/proportion_min.rb