Sha256: e4f04f4f278dd85d349e2fbbe607d3b59c1351907ee4452f05ac0d3e7f013160

Contents?: true

Size: 423 Bytes

Versions: 3

Compression:

Stored size: 423 Bytes

Contents

# pops the top +:float+ item;
# pushes a new +:int+ item,
# with value obtained by applying #to_i to the value
#
# *needs:* 1 +:float+
#
# *pushes:* 1 +:int+
#

class IntFromFloatInstruction < Instruction
  def preconditions?
    needs :float, 1
  end
  def setup
    @arg = @context.pop_value(:float)
  end
  def derive
    @result = ValuePoint.new("int", @arg.to_i)
  end
  def cleanup
    pushes :int, @result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nudge-0.2.9 lib/instructions/conversion/int_from_float.rb
nudge-0.2.8 lib/instructions/conversion/int_from_float.rb
nudge-0.2.7 lib/instructions/conversion/int_from_float.rb