Class: Randsum::Dropper

Inherits:
Object
  • Object
show all
Defined in:
lib/randsum/filters/droppers/dropper.rb

Direct Known Subclasses

HighDropper, LowDropper

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(quantity:, roll:) ⇒ Dropper

Returns a new instance of Dropper.



11
12
13
14
# File 'lib/randsum/filters/droppers/dropper.rb', line 11

def initialize(quantity:, roll:)
  @quantity = quantity
  @roll = roll
end

Instance Attribute Details

#quantityObject (readonly)

Returns the value of attribute quantity.



3
4
5
# File 'lib/randsum/filters/droppers/dropper.rb', line 3

def quantity
  @quantity
end

#rollObject (readonly)

Returns the value of attribute roll.



3
4
5
# File 'lib/randsum/filters/droppers/dropper.rb', line 3

def roll
  @roll
end

Class Method Details

.for(quantity:, extremity:, roll:) ⇒ Object



5
6
7
8
9
# 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

Instance Method Details

#filterObject



16
17
18
19
20
21
22
# File 'lib/randsum/filters/droppers/dropper.rb', line 16

def filter
  return Randsum::Roll.new(
    die: roll.die,
    quantity: roll.quantity,
    result: result
  )
end

#orderedObject

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/randsum/filters/droppers/dropper.rb', line 24

def ordered
  raise NotImplementedError
end