Class: TwentyOne::Hand
- Inherits:
-
Object
- Object
- TwentyOne::Hand
- Defined in:
- lib/twenty_one/hand.rb
Instance Attribute Summary collapse
-
#cards ⇒ Object
readonly
Returns the value of attribute cards.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(cards = []) ⇒ Hand
constructor
A new instance of Hand.
- #value ⇒ Object
Constructor Details
#initialize(cards = []) ⇒ Hand
Returns a new instance of Hand.
7 8 9 |
# File 'lib/twenty_one/hand.rb', line 7 def initialize(cards = []) @cards = cards end |
Instance Attribute Details
#cards ⇒ Object (readonly)
Returns the value of attribute cards.
5 6 7 |
# File 'lib/twenty_one/hand.rb', line 5 def cards @cards end |
Instance Method Details
#clear ⇒ Object
11 12 13 |
# File 'lib/twenty_one/hand.rb', line 11 def clear @cards = [] end |
#value ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/twenty_one/hand.rb', line 15 def value count = 0 @cards.each do |card| count += card.value end count end |