Class: Dicey::RegularDie
- Inherits:
-
NumericDie
- Object
- AbstractDie
- NumericDie
- Dicey::RegularDie
- Defined in:
- lib/dicey/regular_die.rb
Overview
Regular die, which has N sides with numbers from 1 to N.
Constant Summary collapse
- D6 =
Characters to use for small dice.
"⚀⚁⚂⚃⚄⚅"
Instance Attribute Summary
Attributes inherited from AbstractDie
Instance Method Summary collapse
-
#initialize(max) ⇒ RegularDie
constructor
A new instance of RegularDie.
-
#to_s ⇒ String
Dice with 1–6 sides are displayed with a single character from D6.
Methods inherited from AbstractDie
#==, #current, describe, #eql?, from_count, from_list, #hash, #next, rand, #roll, srand
Constructor Details
#initialize(max) ⇒ RegularDie
Returns a new instance of RegularDie.
12 13 14 15 16 17 18 |
# File 'lib/dicey/regular_die.rb', line 12 def initialize(max) unless Integer === max && max.positive? raise DiceyError, "regular dice can contain only positive integers, #{max.inspect} is not" end super((1..max)) end |