Module: BagOfHolding::Dice

Defined in:
lib/bag_of_holding/dice.rb,
lib/bag_of_holding/dice/die.rb,
lib/bag_of_holding/dice/pool.rb,
lib/bag_of_holding/dice/parser.rb,
lib/bag_of_holding/dice/constant.rb,
lib/bag_of_holding/dice/operation.rb,
lib/bag_of_holding/dice/transform.rb,
lib/bag_of_holding/dice/die_result.rb,
lib/bag_of_holding/dice/die_roller.rb,
lib/bag_of_holding/dice/pool_result.rb,
lib/bag_of_holding/dice/pool_factory.rb,
lib/bag_of_holding/dice/die_validator.rb,
lib/bag_of_holding/dice/constant_result.rb,
lib/bag_of_holding/dice/operation_result.rb,
lib/bag_of_holding/dice/addition_operation.rb,
lib/bag_of_holding/dice/division_operation.rb,
lib/bag_of_holding/dice/subtraction_operation.rb,
lib/bag_of_holding/dice/multiplication_operation.rb

Overview

Public: Bag of Holding dice bag. All you need for your myriad of dice rolling needs.

Examples

BagOfHolding::Dice.roll '1d20+5'
# => [BagOfHolding::Dice::OperationResult]

Defined Under Namespace

Classes: AdditionOperation, Constant, ConstantResult, Die, DieResult, DieRoller, DieValidator, DivisionOperation, MultiplicationOperation, Operation, OperationResult, Parser, Pool, PoolFactory, PoolResult, SubtractionOperation, Transform

Class Method Summary collapse

Class Method Details

.roll(str) ⇒ Object



34
35
36
37
38
# File 'lib/bag_of_holding/dice.rb', line 34

def roll(str)
  tree = Parser.new.parse str
  rollables = Transform.new.apply(tree)
  rollables.map(&:roll)
end