Class: BagOfHolding::Dice::DieValidator
- Inherits:
-
Object
- Object
- BagOfHolding::Dice::DieValidator
- Defined in:
- lib/bag_of_holding/dice/die_validator.rb
Overview
Internal: Wraps the logic that determines if a die can be rolled successfully
Instance Attribute Summary collapse
-
#die ⇒ Object
Returns the value of attribute die.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(die:) ⇒ DieValidator
constructor
A new instance of DieValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(die:) ⇒ DieValidator
Returns a new instance of DieValidator.
12 13 14 |
# File 'lib/bag_of_holding/dice/die_validator.rb', line 12 def initialize(die:) self.die = die end |
Instance Attribute Details
#die ⇒ Object
Returns the value of attribute die.
10 11 12 |
# File 'lib/bag_of_holding/dice/die_validator.rb', line 10 def die @die end |
Class Method Details
.valid?(die) ⇒ Boolean
6 7 8 |
# File 'lib/bag_of_holding/dice/die_validator.rb', line 6 def self.valid?(die) new(die: die).valid? end |
Instance Method Details
#valid? ⇒ Boolean
16 17 18 19 20 |
# File 'lib/bag_of_holding/dice/die_validator.rb', line 16 def valid? return false unless die.sides return false if die.reroll && die.explode && die.reroll >= die.explode true end |