Project

dice_box

0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A gem with dices, to get rolling with Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

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.