Class: BagOfHolding::Dice::PoolResult
- Inherits:
-
Object
- Object
- BagOfHolding::Dice::PoolResult
- Defined in:
- lib/bag_of_holding/dice/pool_result.rb
Overview
Internal: contains the results of a rolled pool and the die rolls that got us there.
Instance Attribute Summary collapse
-
#die_results ⇒ Object
Returns the value of attribute die_results.
-
#pool ⇒ Object
Returns the value of attribute pool.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(die_results: nil, value: nil, pool: nil) ⇒ PoolResult
constructor
A new instance of PoolResult.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(die_results: nil, value: nil, pool: nil) ⇒ PoolResult
Returns a new instance of PoolResult.
8 9 10 11 12 |
# File 'lib/bag_of_holding/dice/pool_result.rb', line 8 def initialize(die_results: nil, value: nil, pool: nil) self.die_results = die_results self.value = value self.pool = pool end |
Instance Attribute Details
#die_results ⇒ Object
Returns the value of attribute die_results.
6 7 8 |
# File 'lib/bag_of_holding/dice/pool_result.rb', line 6 def die_results @die_results end |
#pool ⇒ Object
Returns the value of attribute pool.
6 7 8 |
# File 'lib/bag_of_holding/dice/pool_result.rb', line 6 def pool @pool end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/bag_of_holding/dice/pool_result.rb', line 6 def value @value end |
Instance Method Details
#==(other) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/bag_of_holding/dice/pool_result.rb', line 14 def ==(other) return false if value != other.value return false if die_results != other.die_results return false if pool != other.pool true end |
#inspect ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/bag_of_holding/dice/pool_result.rb', line 26 def inspect "#{value} (#{pool})".tap do |str| die_results.each do |die_result| die_result.rolls.each do |roll| str << " [#{roll}]" end end end end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/bag_of_holding/dice/pool_result.rb', line 22 def to_s "#{value} (#{pool})" end |