Class: Dicey::Roller
- Inherits:
-
Object
- Object
- Dicey::Roller
- Defined in:
- lib/dicey/roller.rb
Overview
Let the dice roll!
Instance Method Summary collapse
Instance Method Details
#call(arguments, format:) ⇒ nil
12 13 14 15 16 17 18 19 |
# File 'lib/dicey/roller.rb', line 12 def call(arguments, format:, **) raise DiceyError, "no dice!" if arguments.empty? dice = arguments.flat_map { |definition| die_foundry.cast(definition) } result = dice.sum(&:roll) format.call({ "roll" => result }, AbstractDie.describe(dice)) end |