Class: CardDeck::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/cribbage_game/card.rb

Overview

Represents a card in the deck

Instance Method Summary collapse

Instance Method Details

#idObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cribbage_game/card.rb', line 28

def id
  suit = case @suit
  when Hearts then "h"
  when Spades then "s"
  when Diamonds then "d"
  when Clubs then "c"
  end
  num = case @num
  when "Ace" then "a"
  when "Jack" then "j"
  when "Queen" then "q"
  when "King" then "k"
  when "Joker" then "r"
  else @num.to_s
  end

  num + suit
end

#sort_valueObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/cribbage_game/card.rb', line 17

def sort_value
  case @num
  when "Ace" then 1
  when 2..10 then @num
  when "Jack" then 11
  when "Queen" then 12
  when "King" then 13
  when "Joker" then 14
  end
end

#valueObject

Value of the card



6
7
8
9
10
11
12
13
14
15
# File 'lib/cribbage_game/card.rb', line 6

def value
  case @num
  when "Ace" then 1
  when 2..10 then @num
  when "Jack" then 10
  when "Queen" then 10
  when "King" then 10
  when "Joker" then 10
  end
end