Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/ludy/dices.rb
Instance Method Summary collapse
-
#dices(faces = 20) ⇒ Object
create dices with faces = ?.
-
#roll(faces = 20) ⇒ Object
roll dices (with amounts equal to self.to_i) with faces = ?.
Instance Method Details
#dices(faces = 20) ⇒ Object
create dices with faces = ?
63 64 65 |
# File 'lib/ludy/dices.rb', line 63 def dices faces = 20 Ludy::Dices.new self, faces end |
#roll(faces = 20) ⇒ Object
roll dices (with amounts equal to self.to_i) with faces = ?
54 55 56 57 58 59 60 |
# File 'lib/ludy/dices.rb', line 54 def roll faces = 20 return nil unless self > 0 && self.integer? && faces > 0 && faces.integer? result = 0 1.step(self){ |i| result += rand(faces) + 1 } result end |