Class: ProportionFromFloatInstruction
- Inherits:
-
Instruction
- Object
- Instruction
- ProportionFromFloatInstruction
- Defined in:
- lib/instructions/conversion/proportion_from_float.rb
Overview
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
Instance Attribute Summary
Attributes inherited from Instruction
Instance Method Summary collapse
Methods inherited from Instruction
all_instructions, #go, inherited, #initialize, #needs, #pushes, to_nudgecode
Constructor Details
This class inherits a constructor from Instruction
Instance Method Details
#cleanup ⇒ Object
23 24 25 |
# File 'lib/instructions/conversion/proportion_from_float.rb', line 23 def cleanup pushes :proportion, @result end |
#derive ⇒ Object
19 20 21 |
# File 'lib/instructions/conversion/proportion_from_float.rb', line 19 def derive @result = ValuePoint.new("proportion", @arg % 1.0) end |
#preconditions? ⇒ Boolean
11 12 13 |
# File 'lib/instructions/conversion/proportion_from_float.rb', line 11 def preconditions? needs :float, 1 end |
#setup ⇒ Object
15 16 17 |
# File 'lib/instructions/conversion/proportion_from_float.rb', line 15 def setup @arg = @context.pop_value(:float) end |