Class: RubyPlayingCards::Dealer
- Inherits:
-
Object
- Object
- RubyPlayingCards::Dealer
- Defined in:
- lib/ruby_playing_cards/dealer.rb
Class Method Summary collapse
- .cut!(deck, index = 26) ⇒ Object
- .deal(deck, hand_size: 1, player_count: 1) ⇒ Object
- .draw(deck, card_count = 1) ⇒ Object
- .shuffle(deck) ⇒ Object
Class Method Details
.cut!(deck, index = 26) ⇒ Object
6 7 8 9 |
# File 'lib/ruby_playing_cards/dealer.rb', line 6 def cut!(deck, index=26) top = deck.cards.shift(index) deck.cards = deck.cards + top end |
.deal(deck, hand_size: 1, player_count: 1) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_playing_cards/dealer.rb', line 11 def deal(deck, hand_size: 1, player_count: 1) hands = [] card_total = hand_size * player_count player_count.times do |player_index| hand = build_hand(deck, player_index, card_total, player_count) hands << hand end deck.cards.shift(card_total) hands end |
.draw(deck, card_count = 1) ⇒ Object
24 25 26 |
# File 'lib/ruby_playing_cards/dealer.rb', line 24 def draw(deck, card_count=1) deck.cards.shift card_count end |
.shuffle(deck) ⇒ Object
28 29 30 |
# File 'lib/ruby_playing_cards/dealer.rb', line 28 def shuffle(deck) deck.cards.shuffle! end |