Class: Blackjack::Card
- Inherits:
-
Struct
- Object
- Struct
- Blackjack::Card
- Defined in:
- lib/blackjack/card.rb
Instance Attribute Summary collapse
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#suit ⇒ Object
Returns the value of attribute suit.
Instance Method Summary collapse
-
#ace? ⇒ Boolean
:nocov:.
-
#inspect ⇒ Object
:nocov:.
- #points ⇒ Object
-
#to_s ⇒ Object
:nocov:.
Instance Attribute Details
#rank ⇒ Object
Returns the value of attribute rank
2 3 4 |
# File 'lib/blackjack/card.rb', line 2 def rank @rank end |
#suit ⇒ Object
Returns the value of attribute suit
2 3 4 |
# File 'lib/blackjack/card.rb', line 2 def suit @suit end |
Instance Method Details
#ace? ⇒ Boolean
:nocov:
15 16 17 |
# File 'lib/blackjack/card.rb', line 15 def ace? rank == "A" end |
#inspect ⇒ Object
:nocov:
4 5 6 |
# File 'lib/blackjack/card.rb', line 4 def inspect "#{rank}#{suit[0]}" end |
#points ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/blackjack/card.rb', line 19 def points if ace? 11 else # if it's not a number, it's a 10 (rank.is_a?(Integer) || rank.to_i != 0) ? rank.to_i : 10 end end |
#to_s ⇒ Object
:nocov:
10 11 12 |
# File 'lib/blackjack/card.rb', line 10 def to_s "#{rank} of #{suit}" end |