Class: Card
- Inherits:
-
Object
- Object
- Card
- Defined in:
- lib/99_game.rb
Overview
Represents a card in the deck
Constant Summary collapse
- @@value =
{"Ace" => 1, 4 => 0, 9 => 0, "Jack" => 0, "Joker" => 0, "King" => 99, "Queen" => -10}
Instance Attribute Summary collapse
-
#num ⇒ Object
readonly
Returns the value of attribute num.
Instance Method Summary collapse
- #_value ⇒ Object
-
#initialize(card) ⇒ Card
constructor
A new instance of Card.
- #value ⇒ Object
Constructor Details
#initialize(card) ⇒ Card
Returns a new instance of Card.
32 |
# File 'lib/99_game.rb', line 32 def initialize(card); @num = card; end |
Instance Attribute Details
#num ⇒ Object (readonly)
Returns the value of attribute num.
12 13 14 |
# File 'lib/99_game.rb', line 12 def num @num end |
Instance Method Details
#_value ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/99_game.rb', line 18 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 |
#value ⇒ Object
14 15 16 17 |
# File 'lib/99_game.rb', line 14 def value @@value.default = @num.to_i return @@value[@num] end |