Module: ParaDice::Faces::Arrayed
Overview
a module to be included into a ParaDice::Die or similar object.
Uses an Array object to provide faces, and provides count and
random_face methods
@note, these are strings, but the pattern could easily be symbols, numbers,
json objects, etc. the only difference would be in how you
Constant Summary
Constants included from Die
Instance Attribute Summary collapse
Attributes included from Die
Instance Method Summary collapse
-
#face_count ⇒ Fixnum
returns size of array.
-
#random_face(r = rng) ⇒ String
returns a random face from faces using rng.
Methods included from Die
Instance Attribute Details
#faces ⇒ Object
15 |
# File 'lib/para_dice/faces/arrayed.rb', line 15 attribute :faces, Array[String], default: :quit_if_no_faces |
Instance Method Details
#face_count ⇒ Fixnum
returns size of array
19 20 21 |
# File 'lib/para_dice/faces/arrayed.rb', line 19 def face_count faces.size end |
#random_face(r = rng) ⇒ String
returns a random face from faces using rng
25 26 27 |
# File 'lib/para_dice/faces/arrayed.rb', line 25 def random_face(r = rng) faces.sample(random: r) end |