Class: FifthedSim::LessNode
Instance Method Summary
collapse
#*, #+, #-, #/, #average, #difference_from_average, #or_greater, #or_least, #percentile, #range, #test_then, #to_dice_expression, #to_f, #to_i
Constructor Details
#initialize(lhs, rhs) ⇒ LessNode
Returns a new instance of LessNode.
8
9
10
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 8
def initialize(lhs, rhs)
@lhs, @rhs = lhs, rhs
end
|
Instance Method Details
#distribution ⇒ Object
28
29
30
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 28
def distribution
@lhs.distribution.convolve_least(@rhs.distribution)
end
|
#equation_representation ⇒ Object
32
33
34
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 32
def equation_representation
"min(#{@lhs.equation_representation}, #{@rhs.equation_representation})"
end
|
#expression_equation ⇒ Object
42
43
44
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 42
def expression_equation
"min(#{@lhs.expression_equation}, #{@rhs.expression_equation})"
end
|
#max ⇒ Object
20
21
22
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 20
def max
[@lhs.max, @rhs.max].min
end
|
#min ⇒ Object
24
25
26
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 24
def min
[@lhs.min, @rhs.min].min
end
|
#reroll ⇒ Object
16
17
18
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 16
def reroll
self.class.new(@lhs.reroll, @rhs.reroll)
end
|
#value ⇒ Object
12
13
14
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 12
def value
[@lhs.value, @rhs.value].min
end
|
#value_equation(terminal: false) ⇒ Object
36
37
38
39
40
|
# File 'lib/fifthed_sim/nodes/less_node.rb', line 36
def value_equation(terminal: false)
lhs = @lhs.value_equation(terminal: terminal)
rhs = @rhs.value_equation(terminal: terminal)
"min(#{lhs}, #{rhs})"
end
|