Class: Dicechucker::DiceDropper
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dropped ⇒ Object
Returns the value of attribute dropped.
Attributes inherited from Dice
#modifier, #number_of_dice, #results, #sides, #total
Instance Method Summary collapse
Methods inherited from Dice
Constructor Details
This class inherits a constructor from Dicechucker::Dice
Instance Attribute Details
#dropped ⇒ Object
Returns the value of attribute dropped.
46 47 48 |
# File 'lib/dicechucker/dice.rb', line 46 def dropped @dropped end |
Instance Method Details
#drop_target ⇒ Object
60 61 62 63 |
# File 'lib/dicechucker/dice.rb', line 60 def drop_target raise NotImplementedError, "drop_target must be overwritten by child classes" #defined only for use by subclasses end |
#report ⇒ Object
54 55 56 57 58 |
# File 'lib/dicechucker/dice.rb', line 54 def report rep = super rep << " Dropped #{@dropped}." rep end |
#roll ⇒ Object
48 49 50 51 52 |
# File 'lib/dicechucker/dice.rb', line 48 def roll roll_dice @dropped = @results.delete_at(@results.index(drop_target)) @total = @results.inject(:+) + @modifier end |