Class: RubyPlayingCards::Hand
- Inherits:
-
Object
- Object
- RubyPlayingCards::Hand
- Defined in:
- lib/ruby_playing_cards/hand.rb
Instance Attribute Summary collapse
-
#cards ⇒ Object
Returns the value of attribute cards.
-
#player ⇒ Object
Returns the value of attribute player.
Instance Method Summary collapse
- #add_cards(cards) ⇒ Object
-
#initialize(cards, player) ⇒ Hand
constructor
A new instance of Hand.
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(cards, player) ⇒ Hand
Returns a new instance of Hand.
6 7 8 9 |
# File 'lib/ruby_playing_cards/hand.rb', line 6 def initialize(cards, player) @cards = cards @player = player end |
Instance Attribute Details
#cards ⇒ Object
Returns the value of attribute cards.
4 5 6 |
# File 'lib/ruby_playing_cards/hand.rb', line 4 def cards @cards end |
#player ⇒ Object
Returns the value of attribute player.
4 5 6 |
# File 'lib/ruby_playing_cards/hand.rb', line 4 def player @player end |
Instance Method Details
#add_cards(cards) ⇒ Object
11 12 13 |
# File 'lib/ruby_playing_cards/hand.rb', line 11 def add_cards(cards) @cards << cards end |
#size ⇒ Object
15 16 17 |
# File 'lib/ruby_playing_cards/hand.rb', line 15 def size @cards.size end |
#to_s ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ruby_playing_cards/hand.rb', line 19 def to_s puts "Player #{@player}: " @cards.map do |card| card.to_s end end |