Class: TwentyOne::Deck

Inherits:
Object
  • Object
show all
Defined in:
lib/twenty_one/deck.rb

Constant Summary collapse

@@DECK_LENGTH =
52

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeck

Returns a new instance of Deck.



10
11
12
13
14
15
16
17
# File 'lib/twenty_one/deck.rb', line 10

def initialize
	@cards = [] 

	@cards.concat generate_suit(:clubs)
	@cards.concat generate_suit(:diamonds)
	@cards.concat generate_suit(:hearts)
	@cards.concat generate_suit(:spades)
end

Instance Attribute Details

#cardsObject (readonly)

Returns the value of attribute cards.



8
9
10
# File 'lib/twenty_one/deck.rb', line 8

def cards
  @cards
end

Instance Method Details

#drawObject



23
24
25
# File 'lib/twenty_one/deck.rb', line 23

def draw
	@cards.shift	
end

#shuffleObject



19
20
21
# File 'lib/twenty_one/deck.rb', line 19

def shuffle
	@cards.shuffle!	
end