Class: BagOfHolding::Dice::Pool
- Inherits:
-
Object
- Object
- BagOfHolding::Dice::Pool
- Defined in:
- lib/bag_of_holding/dice/pool.rb
Overview
Internal: Contains information about the number of dice in a pool, the description of those dice and a label if it has one.
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#die ⇒ Object
Returns the value of attribute die.
-
#keep ⇒ Object
Returns the value of attribute keep.
-
#label ⇒ Object
Returns the value of attribute label.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(count: nil, die: nil, label: nil, keep: nil) ⇒ Pool
constructor
A new instance of Pool.
- #roll ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(count: nil, die: nil, label: nil, keep: nil) ⇒ Pool
Returns a new instance of Pool.
8 9 10 11 12 13 |
# File 'lib/bag_of_holding/dice/pool.rb', line 8 def initialize(count: nil, die: nil, label: nil, keep: nil) self.count = count self.die = die self.label = label self.keep = keep end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
6 7 8 |
# File 'lib/bag_of_holding/dice/pool.rb', line 6 def count @count end |
#die ⇒ Object
Returns the value of attribute die.
6 7 8 |
# File 'lib/bag_of_holding/dice/pool.rb', line 6 def die @die end |
#keep ⇒ Object
Returns the value of attribute keep.
6 7 8 |
# File 'lib/bag_of_holding/dice/pool.rb', line 6 def keep @keep end |
#label ⇒ Object
Returns the value of attribute label.
6 7 8 |
# File 'lib/bag_of_holding/dice/pool.rb', line 6 def label @label end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bag_of_holding/dice/pool.rb', line 15 def ==(other) begin return false unless count == other.count return false unless die == other.die return false unless label == other.label rescue NoMethodError return false end true end |
#roll ⇒ Object
27 28 29 30 31 |
# File 'lib/bag_of_holding/dice/pool.rb', line 27 def roll BagOfHolding::Dice::PoolResult.new die_results: die_results, value: value, pool: self end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/bag_of_holding/dice/pool.rb', line 33 def to_s "#{count}#{die}" end |