Class: Shithead::Card

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#suiteObject (readonly)

Returns the value of attribute suite.



24
25
26
# File 'lib/shithead/card.rb', line 24

def suite
  @suite
end

#valueObject (readonly)

Returns the value of attribute value.



24
25
26
# File 'lib/shithead/card.rb', line 24

def value
  @value
end

Instance Method Details

#rankObject



31
32
33
# File 'lib/shithead/card.rb', line 31

def rank
  RANKS[value]
end

#to_sObject



35
36
37
# File 'lib/shithead/card.rb', line 35

def to_s
  "#{value}#{SUITES[suite]}"
end