Class: Dicechucker::DiceDropper

Inherits:
Dice
  • Object
show all
Defined in:
lib/dicechucker/dice.rb

Direct Known Subclasses

DiceDropHigh, DiceDropLow

Instance Attribute Summary collapse

Attributes inherited from Dice

#modifier, #number_of_dice, #results, #sides, #total

Instance Method Summary collapse

Methods inherited from Dice

#==, #initialize

Constructor Details

This class inherits a constructor from Dicechucker::Dice

Instance Attribute Details

#droppedObject

Returns the value of attribute dropped.



46
47
48
# File 'lib/dicechucker/dice.rb', line 46

def dropped
  @dropped
end

Instance Method Details

#drop_targetObject

Raises:

  • (NotImplementedError)


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

#reportObject



54
55
56
57
58
# File 'lib/dicechucker/dice.rb', line 54

def report
  rep = super
  rep << " Dropped #{@dropped}."
  rep
end

#rollObject



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