Class: FifthedSim::DivisionNode

Inherits:
DiceExpression show all
Defined in:
lib/fifthed_sim/nodes/division_node.rb

Instance Method Summary collapse

Methods inherited from DiceExpression

#*, #+, #-, #/, #average, #difference_from_average, #max, #min, #or_greater, #or_least, #percentile, #range, #test_then, #to_dice_expression, #to_f, #to_i

Constructor Details

#initialize(num, div) ⇒ DivisionNode

Returns a new instance of DivisionNode.



7
8
9
10
# File 'lib/fifthed_sim/nodes/division_node.rb', line 7

def initialize(num, div)
  @lhs = num
  @rhs = div
end

Instance Method Details

#distributionObject



20
21
22
# File 'lib/fifthed_sim/nodes/division_node.rb', line 20

def distribution
  @lhs.distribution.convolve_divide(@rhs.distribution)
end

#rerollObject



16
17
18
# File 'lib/fifthed_sim/nodes/division_node.rb', line 16

def reroll
  self.class.new(@lhs.reroll, @rhs.reroll)
end

#valueObject



12
13
14
# File 'lib/fifthed_sim/nodes/division_node.rb', line 12

def value
  @lhs.value / @rhs.value
end