DiceBox

Dice Box

Gem Version Build Status Code Climate Test Coverage

A gem of dices, to get rolling with Ruby.

Supported Ruby versions:

  • MRI 2.1.0
  • MRI 2.0.0
  • JRuby 1.7.13

Installation

Via RubyGems:

$ gem install dice_box

Or in a Gemfile:

gem 'dice_box'

Usage

Complete documentation available here.

  • DiceBox::Dice (rolling dices) ```ruby # Roll a dice with 7 sides DiceBox::Dice.roll(7) # => 4

# Roll 3 dices with 12 sides DiceBox::Dice.roll(12, 3) # => 27

# Using an instance dice = DiceBox::Dice.new(12) dice.result # => nil dice.roll # => 24 dice.result # => 24


- [DiceBox::Dice::Sides](http://rubydoc.info/github/rafaelgonzalez/dice_box/DiceBox/Dice/Side) (cheating with sides weights)
  ```ruby
  dice = DiceBox::Dice.new(3)
  dice.sides[0].weight = 0.0
  dice.sides[1].weight = 2.0

  dice.roll # => 2
  dice.roll # => 3
  dice.roll # => 2
  dice.roll # => 2
  dice.roll # => 2
  dices = [DiceBox::Dice.new(6), DiceBox::Dice.new(20), DiceBox::Dice.new(100)]
  cup = DiceBox::Cup.new(dices)

  cup.result # => nil
  cup.roll # => 103
  cup.result # => 103

  cup.dices[0].result # => 2
  cup.dices[1].result # => 19
  cup.dices[2].result # => 88

Versioning

DiceBox follows the principles of semantic versioning.

Given a version number MAJOR.MINOR.PATCH:

  • MAJOR is incremented when incompatible API changes are made
  • MINOR is incremented when functionalities are added in a backwards-compatible manner
  • PATCH is incremented when backwards-compatible bug fixes are made

Similar Libraries

License

Copyright :copyright: 2014 Rafaƫl Gonzalez

Released under the terms of the MIT licence. See the LICENSE file for more details.