Class: FifthedSim::BlockNode
Instance Method Summary
collapse
#*, #+, #-, #/, #average, #difference_from_average, #max, #min, #or_greater, #or_least, #percentile, #range, #test_then, #to_dice_expression, #to_f, #to_i
Constructor Details
#initialize(arg, &block) ⇒ BlockNode
Returns a new instance of BlockNode.
9
10
11
12
13
14
|
# File 'lib/fifthed_sim/nodes/block_node.rb', line 9
def initialize(arg, &block)
@arg = arg
@block = block
@current_expression = block.call(arg.value)
@current_value = @current_expression.value
end
|
Instance Method Details
#distribution ⇒ Object
24
25
26
|
# File 'lib/fifthed_sim/nodes/block_node.rb', line 24
def distribution
@arg.distribution.results_when(&distribution_block)
end
|
#reroll ⇒ Object
20
21
22
|
# File 'lib/fifthed_sim/nodes/block_node.rb', line 20
def reroll
self.class.new(@arg.reroll, &@block)
end
|
#value ⇒ Object
16
17
18
|
# File 'lib/fifthed_sim/nodes/block_node.rb', line 16
def value
@current_value
end
|
#value_equation(terminal: false) ⇒ Object
28
29
30
31
32
|
# File 'lib/fifthed_sim/nodes/block_node.rb', line 28
def value_equation(terminal: false)
arg = @arg.value_equation(terminal: terminal)
ce = @current_expression.value_equation(terminal: terminal)
"blockNode(#{arg} => #{ce})"
end
|