Class: Patience::Deck

Inherits:
Pile show all
Defined in:
lib/patience/deck.rb

Overview

Patience::Deck creates a play deck object, which contains 52 cards (just like a real world deck!).

deck = Deck.new(cards) # Just imagine, that we've already created those!
deck.cards.size #=> 52

Instance Attribute Summary

Attributes inherited from Pile

#background, #cards

Instance Method Summary collapse

Methods inherited from Pile

#<<, #draw_on, #hit?, #last_card?, #overlaps?, #pos=, #shuffle_off!

Constructor Details

#initializeDeck

Returns a new instance of Deck.



12
13
14
15
16
17
18
# File 'lib/patience/deck.rb', line 12

def initialize
  @cards = []

  Card::Rank.descendants.size.times do |r|
    Card::Suit.descendants.size.times { |s| @cards << Card.new(r+1, s+1) }
  end
end