Class: Dicey::CLI::Roller Private
- Inherits:
-
Object
- Object
- Dicey::CLI::Roller
- Defined in:
- lib/dicey/cli/roller.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Let the dice roll!
This is the implementation of roll mode for the CLI.
Instance Method Summary collapse
Instance Method Details
#call(arguments, format:) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dicey/cli/roller.rb', line 23 def call(arguments, format:, **) raise DiceyError, "no dice!" if arguments.empty? dice = arguments.flat_map { |definition| die_foundry.cast(definition) } result = roll_dice(dice) format.call({ "roll" => rational_to_integer(result) }, AbstractDie.describe(dice)) rescue TypeError warn_about_vector_number raise DiceyError, "can not roll dice with non-numeric sides!" end |