Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master

Merge pull request #24 from 2rk/master

Feature: Add ability to exclude rank(s) and support multiple decks
latest commit e6e7fda255
@jdan authored
Failed to load latest commit information.
lib Add the ability to add multiple decks
spec Add the ability to add multiple decks
.gitignore some annotations on .gitignore
.rspec added gemspec, .rvmrc, /spec, and git ignore
.travis.yml removed support for Travis running ruby 1.8.7
Gemfile Upgrade to RSpec 3
LICENSE.txt Updated with an example of recent pull requests
Rakefile implemented rake task to generate coveralls report
rubycards.gemspec version bump and license in gemspec


Build Status Coverage Status

Rubycards is a library to emulate playing cards (cards, hands, decks). As an added bonus, you can display the cards as tiny pictures. I'm mainly doing this as an exercise to learn better Ruby organization, as well as documentation and testing. More importantly it's just fun.

See the extended documentation:



Add this line to your application's Gemfile:

gem 'rubycards'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rubycards


Here's a trivial example of declaring a new deck, shuffling, and drawing 5 cards into a hand:

require 'rubycards'
include RubyCards

hand =
deck =


hand.draw(deck, 5)

puts hand

Which produces the image at the top of this README.

Here's a second example showing 2 decks, with the 2 and Jacks removed, shuffling, and drawing 10 cards into a hand:

require 'rubycards'
include RubyCards

hand =
deck = 2, exclude_rank: [2, 'Jack'])


hand.draw(deck, 10)

puts hand


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.