Class: RubyPlayingCards::Card
- Inherits:
-
Object
- Object
- RubyPlayingCards::Card
- Defined in:
- lib/ruby_playing_cards/card.rb
Constant Summary collapse
- FACE_CARDS =
{ 1 => :A, 13 => :K, 12 => :Q, 11 => :J }
Instance Attribute Summary collapse
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#suit ⇒ Object
Returns the value of attribute suit.
Instance Method Summary collapse
-
#initialize(rank, suit) ⇒ Card
constructor
A new instance of Card.
- #to_s ⇒ Object
Constructor Details
#initialize(rank, suit) ⇒ Card
Returns a new instance of Card.
8 9 10 11 |
# File 'lib/ruby_playing_cards/card.rb', line 8 def initialize(rank, suit) @rank = FACE_CARDS[rank] || rank @suit = suit end |
Instance Attribute Details
#rank ⇒ Object
Returns the value of attribute rank.
6 7 8 |
# File 'lib/ruby_playing_cards/card.rb', line 6 def rank @rank end |
#suit ⇒ Object
Returns the value of attribute suit.
6 7 8 |
# File 'lib/ruby_playing_cards/card.rb', line 6 def suit @suit end |
Instance Method Details
#to_s ⇒ Object
13 14 15 |
# File 'lib/ruby_playing_cards/card.rb', line 13 def to_s "#{@suit}#{@rank}" end |