Class: PokerTrump::Card
- Inherits:
-
Object
- Object
- PokerTrump::Card
- Defined in:
- lib/poker_trump/card.rb
Constant Summary collapse
- RANKS =
%w[A 2 3 4 5 6 7 8 9 T J Q K].freeze
- SUITS =
%i[s h d c].freeze
- RANK_VALUE =
{ '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, 'T' => 10, 'J' => 11, 'Q' => 12, 'K' => 13, 'A' => 14 }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_string(string) ⇒ Object
28 29 30 |
# File 'lib/poker_trump/card.rb', line 28 def from_string(string) new(rank: string[0], suit: string[1]) end |
Instance Method Details
#==(other_card) ⇒ Object
41 42 43 |
# File 'lib/poker_trump/card.rb', line 41 def ==(other_card) rank == other_card.rank && suit == other_card.suit end |
#rank_value ⇒ Object
33 34 35 |
# File 'lib/poker_trump/card.rb', line 33 def rank_value RANK_VALUE[rank] end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/poker_trump/card.rb', line 37 def to_s "#{rank}#{suit}" end |