Class: BagOfHolding::Dice::PoolFactory
- Inherits:
-
Object
- Object
- BagOfHolding::Dice::PoolFactory
- Defined in:
- lib/bag_of_holding/dice/pool_factory.rb
Overview
Internal: This class takes the parser output describing a dice pool and builds the correct pool object.
Constant Summary collapse
- DIE_OPTIONS =
[:sides, :reroll, :explode]
- DIE_DEFAULTS =
{ explode: ->(attrs) { attrs[:sides] }, reroll: ->(_attrs) { 1 } }
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(count: nil, die:, label: nil) ⇒ PoolFactory
constructor
A new instance of PoolFactory.
Constructor Details
#initialize(count: nil, die:, label: nil) ⇒ PoolFactory
Returns a new instance of PoolFactory.
17 18 19 20 21 |
# File 'lib/bag_of_holding/dice/pool_factory.rb', line 17 def initialize(count: nil, die:, label: nil) self.raw_count = count self.raw_die = die self.raw_label = label end |
Class Method Details
.build(count: nil, die:, label: nil) ⇒ Object
6 7 8 |
# File 'lib/bag_of_holding/dice/pool_factory.rb', line 6 def self.build(count: nil, die:, label: nil) new(count: count, die: die, label: label).build end |
Instance Method Details
#build ⇒ Object
23 24 25 26 27 28 |
# File 'lib/bag_of_holding/dice/pool_factory.rb', line 23 def build BagOfHolding::Dice::Pool.new count: pool_count, die: die, label: raw_label, keep: keep end |