Project

cardshark

0.0
No commit activity in last 3 years
No release in over 3 years
A library for building decks of cards.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 4.7.3
~> 3.9.0
~> 0.79.0
 Project Readme

Cardshark

Example usage:

require 'cardshark'

class Deck < Cardshark::Deck; end
class Card < Cardshark::Card; end
class Rank < Cardshark::Dimension; end
class Suit < Cardshark::Dimension; end

ranks = [
  :ace,
  :two,
  :three,
  :four,
  :five,
  :six,
  :seven,
  :eight,
  :nine,
  :ten,
  :jack,
  :queen,
  :king
].each do |name|
  Rank.new(name)
end

suits = [
  :clubs,
  :diamonds,
  :hearts,
  :spades
].each do |name|
  Suit.new(name)
end

deck = Deck.new do
  cards = []
  Suit.all.each do |suit|
    Rank.all.each do |rank|
      cards << Card.new(rank, suit)
    end
  end
  cards
end