Skip to content

Instantly share code, notes, and snippets.

@heftig
Forked from keppy/gist:2835207
Created May 30, 2012 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heftig/2835290 to your computer and use it in GitHub Desktop.
Save heftig/2835290 to your computer and use it in GitHub Desktop.
class PokerGame
include Enumerable
include Comparable
attr_reader :hands, :deck
RANKS = %w{ 2 3 4 5 6 7 8 9 T J Q K A }
SUITS = %w{ S H D C }
def initialize(hands, cards)
@deck = RANKS.product(SUITS).map(&:join)
@deck.shuffle!
@hands = hands.times.map { @deck.pop(cards) }
end
end
pg = PokerGame.new(2, 5)
p pg.hands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment