Sha256: ee7ddb106a1f9995cd29a7b1bb3c3282e8e33b6d1fa37f59b542e483826a4352

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

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

class ProportionMaxInstruction < 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].max)
  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_max.rb