Sha256: 9b1471bcb32d599a3bdc056bc52ab3b187c1a16cfd62d45f76f3e7b008a650ed

Contents?: true

Size: 468 Bytes

Versions: 1

Compression:

Stored size: 468 Bytes

Contents

# pops the top +:float+ item;
# pushes a new +:proportion+ item,
# with value obtained by taking the float modulo 1.0
#
# *needs:* 1 +:float+
#
# *pushes:* 1 +:proportion+
#

class ProportionFromFloatInstruction < Instruction
  def preconditions?
    needs :float, 1
  end
  
  def setup
    @arg = @context.pop_value(:float)
  end
  
  def derive
    @result = ValuePoint.new("proportion", @arg % 1.0)
  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/conversion/proportion_from_float.rb