🎲 A gem of dices, to get rolling with Ruby.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.cane
.gitignore
.rspec
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
dice.jpg
dice_box.gemspec

README.md

DiceBox

Dice Box

Gem Version Dependency Status Build Status Test Coverage Code Climate Inline docs

A gem of dices, to get rolling with Ruby.

Supported Ruby versions:

  • MRI 2.2.0
  • MRI 2.1.5
  • MRI 2.1.0
  • MRI 2.0.0
  • MRI 1.9.3

Installation

Via RubyGems:

$ gem install dice_box

Or in a Gemfile:

gem 'dice_box'

Usage

Complete documentation available here.

  • DiceBox::Dice (rolling dices)

    # 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 (cheating with sides weights)

    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
  • DiceBox::Cup (rolling multiple dice instances)

    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 2.0.0.

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 ©️ 2014 Rafaël Gonzalez

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