Class: TwentyOne::Deck
- Inherits:
-
Object
- Object
- TwentyOne::Deck
- Defined in:
- lib/twenty_one/deck.rb
Constant Summary collapse
- @@DECK_LENGTH =
52
Instance Attribute Summary collapse
-
#cards ⇒ Object
readonly
Returns the value of attribute cards.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize ⇒ Deck
constructor
A new instance of Deck.
- #shuffle ⇒ Object
Constructor Details
#initialize ⇒ Deck
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
#cards ⇒ Object (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
#draw ⇒ Object
23 24 25 |
# File 'lib/twenty_one/deck.rb', line 23 def draw @cards.shift end |
#shuffle ⇒ Object
19 20 21 |
# File 'lib/twenty_one/deck.rb', line 19 def shuffle @cards.shuffle! end |