class Randsum::Dropper
Attributes
quantity[R]
roll[R]
Public Class Methods
for(quantity:, extremity:, roll:)
click to toggle source
# File lib/randsum/filters/droppers/dropper.rb, line 5 def self.for(quantity:, extremity:, roll:) Object.const_get( "Randsum::#{extremity.to_s.gsub("est","").capitalize}Dropper" ).new(quantity: quantity, roll: roll) end
new(quantity:, roll:)
click to toggle source
# File lib/randsum/filters/droppers/dropper.rb, line 11 def initialize(quantity:, roll:) @quantity = quantity @roll = roll end
Public Instance Methods
filter()
click to toggle source
# File lib/randsum/filters/droppers/dropper.rb, line 16 def filter return Randsum::Roll.new( die: roll.die, quantity: roll.quantity, result: result ) end
ordered()
click to toggle source
# File lib/randsum/filters/droppers/dropper.rb, line 24 def ordered raise NotImplementedError end
Private Instance Methods
remainder()
click to toggle source
# File lib/randsum/filters/droppers/dropper.rb, line 34 def remainder roll.length - quantity end
result()
click to toggle source
# File lib/randsum/filters/droppers/dropper.rb, line 30 def result ordered.first(remainder) end