Class: Card
- Inherits:
-
Object
- Object
- Card
- Defined in:
- lib/ninety_eight.rb
Overview
The objects that are used in gameplay. Found in $deck.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#num ⇒ Object
readonly
The number on the card.
Instance Method Summary collapse
-
#initialize(card) ⇒ Card
constructor
Creates a new card.
-
#value ⇒ Object
Returns the Card’s value based on its :num attribute.
Constructor Details
#initialize(card) ⇒ Card
Creates a new card.
17 |
# File 'lib/ninety_eight.rb', line 17 def initialize(card); @num = card; end |
Instance Attribute Details
#num ⇒ Object (readonly)
The number on the card
15 16 17 |
# File 'lib/ninety_eight.rb', line 15 def num @num end |
Instance Method Details
#value ⇒ Object
Returns the Card’s value based on its :num attribute.
18 19 20 21 22 23 24 25 26 |
# File 'lib/ninety_eight.rb', line 18 def value # Returns the Card's value based on its :num attribute. case self.num when "Ace" then return 1 when 2..9 then return self.num when 10 then return -10 when "King" then return 98 #Sets value to 98 else; return 0 end end |