Class: Shithead::Card
- Inherits:
-
Object
- Object
- Shithead::Card
- Defined in:
- lib/shithead/card.rb
Constant Summary collapse
- RANKS =
{ "10" => 1, "A" => 2, "2" => 3, "K" => 4, "Q" => 5, "J" => 6, "9" => 8, "8" => 9, "7" => 10, "6" => 11, "5" => 12, "4" => 13, "3" => 14 }
- SUITES =
{ "Diamonds" => "♦️", "Hearts" => "♥️", "Spades" => "♠️", "Clubs" => "♣️" }
Instance Attribute Summary collapse
-
#suite ⇒ Object
readonly
Returns the value of attribute suite.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(suite, value) ⇒ Card
constructor
A new instance of Card.
- #rank ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(suite, value) ⇒ Card
26 27 28 29 |
# File 'lib/shithead/card.rb', line 26 def initialize(suite, value) @suite = suite @value = value end |
Instance Attribute Details
#suite ⇒ Object (readonly)
Returns the value of attribute suite.
24 25 26 |
# File 'lib/shithead/card.rb', line 24 def suite @suite end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
24 25 26 |
# File 'lib/shithead/card.rb', line 24 def value @value end |
Instance Method Details
#rank ⇒ Object
31 32 33 |
# File 'lib/shithead/card.rb', line 31 def rank RANKS[value] end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/shithead/card.rb', line 35 def to_s "#{value}#{SUITES[suite]}" end |