Skip to content

Instantly share code, notes, and snippets.

@nfriend21
Created November 21, 2012 16:41
Show Gist options
  • Save nfriend21/4125932 to your computer and use it in GitHub Desktop.
Save nfriend21/4125932 to your computer and use it in GitHub Desktop.
21
SUITS = %w{clubs hearts spades diamonds}
VALUES = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]
AMOUNTS = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
Card = Struct.new(:value, :suit, :amount)
class Deck < Array
def initialize
SUITS.each do |suit|
VALUES.each_with_index do |value, index|
self << Card.new(value, suit, AMOUNTS[index])
end
end
end
def shuffle
self.class.new
self.shuffle
self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment