Class: PlayingCards::Card
- Inherits:
-
Struct
- Object
- Struct
- PlayingCards::Card
- Defined in:
- lib/playing_cards/card.rb
Constant Summary collapse
- SUITS =
%w(hearts clubs spades diamonds).map(&:to_sym)
- RANKS =
%w(ace two three four five six seven eight nine ten jack queen king).map(&:to_sym)
- VALUES =
%w(11 2 3 4 5 6 7 8 9 10 10 10 10)
- SBITS =
%w(B D A C)
- RBITS =
%w(1 2 3 4 5 6 7 8 9 A B D E)
Instance Attribute Summary collapse
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#suit ⇒ Object
Returns the value of attribute suit.
Instance Method Summary collapse
- #backside_to_unicode ⇒ Object
- #to_s ⇒ Object
- #to_unicode ⇒ Object (also: #inspect)
- #value ⇒ Object
Instance Attribute Details
#rank ⇒ Object
Returns the value of attribute rank
6 7 8 |
# File 'lib/playing_cards/card.rb', line 6 def rank @rank end |
#suit ⇒ Object
Returns the value of attribute suit
6 7 8 |
# File 'lib/playing_cards/card.rb', line 6 def suit @suit end |
Instance Method Details
#backside_to_unicode ⇒ Object
23 24 25 |
# File 'lib/playing_cards/card.rb', line 23 def backside_to_unicode "\u{1F0A0}" end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/playing_cards/card.rb', line 14 def to_s "#{rank.to_s} of #{suit.to_sym}" end |
#to_unicode ⇒ Object Also known as: inspect
18 19 20 |
# File 'lib/playing_cards/card.rb', line 18 def to_unicode ["1F0#{suit_bit}#{rank_bit}".hex].pack("U") end |