Class: BlackJack::Deck
- Inherits:
-
Object
- Object
- BlackJack::Deck
- Defined in:
- lib/black_jack/deck.rb
Instance Attribute Summary collapse
-
#new_deck ⇒ Object
Returns the value of attribute new_deck.
Instance Method Summary collapse
- #create_a_deck ⇒ Object
- #deal_a_card(new_deck = @new_deck) ⇒ Object
-
#deal_specific_card(deck = @new_deck, index_number) ⇒ Object
this method was written soley for the purpose of testing.
-
#initialize ⇒ Deck
constructor
A new instance of Deck.
- #shuffle_deck ⇒ Object
Constructor Details
#initialize ⇒ Deck
Returns a new instance of Deck.
6 7 |
# File 'lib/black_jack/deck.rb', line 6 def initialize end |
Instance Attribute Details
#new_deck ⇒ Object
Returns the value of attribute new_deck.
4 5 6 |
# File 'lib/black_jack/deck.rb', line 4 def new_deck @new_deck end |
Instance Method Details
#create_a_deck ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/black_jack/deck.rb', line 9 def create_a_deck new_suits = %w(hearts spades clubs diamonds ) new_value = %w(Ace 2 3 4 5 6 7 8 9 10 Jack Queen King) @new_deck = Array.new #creates a new array by combining the information in the #above two new_value.each do |card| new_suits.each do |suited| @new_deck << "#{card} of #{suited}" end end end |
#deal_a_card(new_deck = @new_deck) ⇒ Object
26 27 28 29 |
# File 'lib/black_jack/deck.rb', line 26 def deal_a_card new_deck=@new_deck dealt_card = @new_deck.pop dealt_card end |
#deal_specific_card(deck = @new_deck, index_number) ⇒ Object
this method was written soley for the purpose of testing
31 32 33 34 |
# File 'lib/black_jack/deck.rb', line 31 def deal_specific_card deck=@new_deck, index_number dealt_card = @new_deck[index_number] dealt_card end |
#shuffle_deck ⇒ Object
22 23 24 |
# File 'lib/black_jack/deck.rb', line 22 def shuffle_deck @new_deck = @new_deck.shuffle end |