Class: BagOfHolding::Dice::PoolResult

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_resultsObject

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

#poolObject

Returns the value of attribute pool.



6
7
8
# File 'lib/bag_of_holding/dice/pool_result.rb', line 6

def pool
  @pool
end

#valueObject

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

#inspectObject



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_sObject



22
23
24
# File 'lib/bag_of_holding/dice/pool_result.rb', line 22

def to_s
  "#{value} (#{pool})"
end