Class: DiceRoller
- Inherits:
-
Object
- Object
- DiceRoller
- Includes:
- Cinch::Plugin
- Defined in:
- lib/plugins/dice_roller.rb
Instance Method Summary collapse
Instance Method Details
#execute(m) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/plugins/dice_roller.rb', line 12 def execute(m) command = /\d+d\d+/.match(m.).to_s num_of_dice = command.split('d')[0].to_i num_of_sides = command.split('d')[1].to_i reply = '' num_of_dice.times { reply << rand(1..num_of_sides).to_s + ' ' } m.reply reply end |
#help ⇒ Object
4 5 6 |
# File 'lib/plugins/dice_roller.rb', line 4 def help '!roll XdY - rolls dice (replace X with number of dice and Y with number of sides)' end |