Class: CardDeck::Card

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

Constant Summary collapse

NUM =

Legal arguments for Card#new.

%w(Ace King Queen Jack Joker) + (2..10).to_a

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(num) ⇒ Card

Creates a new card. Parameter num is the card’s number.



11
12
13
14
15
16
17
# File 'lib/card_deck.rb', line 11

def initialize(num)
	unless NUM.include? num
	raise CardError, 'Illegal argument for parameter num'
	else
		@num = num
	end
end

Instance Attribute Details

#numObject

The card’s number. Must be Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, or Joker



9
10
11
# File 'lib/card_deck.rb', line 9

def num
  @num
end