Module: ParaDice::Die Abstract
- Included in:
- Faces::Arrayed, NumberedDie, StringDie
- Defined in:
- lib/para_dice/die.rb
Overview
This module is abstract.
A module meant to be the basis of a custom Die object with behaviour included from this die.
Constant Summary collapse
- ERROR_MSG =
': Must be implemented in your Die class or included in a faces module.'
Instance Attribute Summary collapse
-
#description ⇒ String
Default ”.
-
#name ⇒ String
Required.
-
#rng ⇒ Random
Default Random.new.
Instance Method Summary collapse
- #face_count ⇒ Object abstract
- #faces ⇒ Object abstract
- #random_face(this_rng = rng) ⇒ Object abstract
-
#roll(roll_rng = rng) ⇒ Object
for overloading and calling super on to allow more complex arrangements of face and dice behavior modules.
Instance Attribute Details
#description ⇒ String
Returns default ”.
30 |
# File 'lib/para_dice/die.rb', line 30 attribute :name, String, default: :quit_if_no_name |
#name ⇒ String
Returns required.
30 |
# File 'lib/para_dice/die.rb', line 30 attribute :name, String, default: :quit_if_no_name |
#rng ⇒ Random
Returns default Random.new.
30 |
# File 'lib/para_dice/die.rb', line 30 attribute :name, String, default: :quit_if_no_name |
Instance Method Details
#face_count ⇒ Object
This method is abstract.
Implement in Include-able Module and override #face_count to implement a custom Threadable class.
44 45 46 |
# File 'lib/para_dice/die.rb', line 44 def face_count raise NotImplementedError.new ('face_count' + ERROR_MSG) end |
#faces ⇒ Object
This method is abstract.
Implement in Include-able Module and override #face_count to implement a custom Threadable class.
56 57 58 |
# File 'lib/para_dice/die.rb', line 56 def faces raise NotImplementedError.new ('faces' + ERROR_MSG) end |
#random_face(this_rng = rng) ⇒ Object
This method is abstract.
Implement in Include-able Module and override #face_count to implement a custom Threadable class.
50 51 52 |
# File 'lib/para_dice/die.rb', line 50 def random_face(this_rng = rng) raise NotImplementedError.new ('random_face' + ERROR_MSG) end |
#roll(roll_rng = rng) ⇒ Object
for overloading and calling super on to allow more complex arrangements of
face and dice behavior modules
38 39 40 |
# File 'lib/para_dice/die.rb', line 38 def roll(roll_rng = rng) random_face(roll_rng) end |