Class: Card

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

Overview

The objects that are used in gameplay. Found in $deck.

Direct Known Subclasses

UserCard

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#numObject (readonly)

The number on the card



15
16
17
# File 'lib/ninety_eight.rb', line 15

def num
  @num
end

Instance Method Details

#valueObject

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