Class: Card

Inherits:
Object
  • Object
show all
Defined in:
lib/99_game.rb

Overview

Represents a card in the deck

Direct Known Subclasses

UserCard

Constant Summary collapse

@@value =
{"Ace" => 1, 4 => 0, 9 => 0, "Jack" => 0, "Joker" => 0, "King" => 99, "Queen" => -10}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card) ⇒ Card

Returns a new instance of Card.



23
# File 'lib/99_game.rb', line 23

def initialize(card); @num = card; end

Instance Attribute Details

#numObject (readonly)

Returns the value of attribute num.



3
4
5
# File 'lib/99_game.rb', line 3

def num
  @num
end

Instance Method Details

#_valueObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/99_game.rb', line 9

def _value
	return case @num
		when "Ace" then 1
		when 2..3 then @num
		when 4 then 0
		when 5..8 then @num
		when 9 then 0
		when 10 then 10
		when "Jack" then 0
		when "Queen" then -10
		when "King" then 99
		when "Joker" then 0
	end
end

#valueObject



5
6
7
8
# File 'lib/99_game.rb', line 5

def value
	@@value.default = @num.to_i
	return @@value[@num]
end