class Fixnum
Allow .to_dice_expression on Fixnum
We sneakily monkey-patch Fixnum
here, to allow us to use a nice syntax for factorials.
We only do this if somebody hasn't done it already, in case ruby adds this to the standard one day.
Public Instance Methods
d(o)
click to toggle source
Enable you to create dice rolls via `3.d(6)` syntax. This returns a DiceResult, meaning that you can add them together to form a calculation.
# File lib/fifthed_sim.rb, line 37 def d(o) FifthedSim.d(self, o) end
factorial()
click to toggle source
Mathematical factorial
# File lib/fifthed_sim/nodes/multi_node.rb, line 13 def factorial (1..self).inject(:*) || 1 end
to_dice_expression()
click to toggle source
# File lib/fifthed_sim/dice_expression.rb, line 106 def to_dice_expression FifthedSim::NumberNode.new(self) end