class Randsum::Replacer
Attributes
roll[R]
target[R]
with[R]
Public Class Methods
for(target:, with:, roll:)
click to toggle source
# File lib/randsum/filters/replacers/replacer.rb, line 5 def self.for(target:, with:, roll:) Randsum::Replacer.new( target: target, with: with, roll: roll, ) end
new(target:, with:, roll:)
click to toggle source
# File lib/randsum/filters/replacers/replacer.rb, line 13 def initialize(target:, with:, roll:) @target = ReplacerTarget.for(target, roll: roll) @with = ReplacerValue.for(with, roll: roll) @roll = roll end
Public Instance Methods
filter()
click to toggle source
# File lib/randsum/filters/replacers/replacer.rb, line 19 def filter return Randsum::Roll.new( die: roll.die, quantity: roll.quantity, result: result ) end
result()
click to toggle source
# File lib/randsum/filters/replacers/replacer.rb, line 27 def result (roll.result - target.match) + transformed end
transformed()
click to toggle source
# File lib/randsum/filters/replacers/replacer.rb, line 31 def transformed with.transform(target.match) end