Sha256: f72c70dc090cb2ac939ae65dc31496aa67ad3163bfde75cbeb0ca44240daba9c

Contents?: true

Size: 524 Bytes

Versions: 1

Compression:

Stored size: 524 Bytes

Contents

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

class ProportionMultiplyInstruction < 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)
  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_multiply.rb