class FifthedSim::NumberNode
Normally we handle numbers by use of a refinement on Fixnum
However, in some cases, we may have the fixnum as the start of an expression. In this case, we have a problem, because Fixnum#+ is not overloaded to return a DiceNode. In this case, we must use this, a NumberNode
. NumberNodes wrap a number.
Public Class Methods
new(arg)
click to toggle source
# File lib/fifthed_sim/nodes/number_node.rb, line 11 def initialize(arg) unless arg.is_a? Fixnum raise ArgumentError, "#{arg.inspect} is not a fixnum" end @value = arg end
Public Instance Methods
distribution()
click to toggle source
# File lib/fifthed_sim/nodes/number_node.rb, line 18 def distribution Distribution.for(@value) end
expression_equation()
click to toggle source
# File lib/fifthed_sim/nodes/number_node.rb, line 34 def expression_equation @value.to_s end
reroll()
click to toggle source
# File lib/fifthed_sim/nodes/number_node.rb, line 26 def reroll self.class.new(@value) end
value()
click to toggle source
# File lib/fifthed_sim/nodes/number_node.rb, line 22 def value @value end
value_equation(terminal: false)
click to toggle source
# File lib/fifthed_sim/nodes/number_node.rb, line 30 def value_equation(terminal: false) @value.to_s end