Class: CardDeck::Deck

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

Overview

The deck

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = Hash.new(false)) ⇒ Deck

Creates a new Deck. Includes Jokers when parmeter args == true



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/deck.rb', line 5

def initialize(args=Hash.new(false)) # Creates a new Deck. Includes Jokers when parmeter args == {jokers: true}
	@cards = Array.new
	for suit in Card::Suit
		stock 'Ace', suit
		for num in (2..10).to_a; stock num, suit; end
		stock 'Jack', suit
		stock 'Queen', suit
		stock 'King', suit
	end
	2.times {stock 'Joker'} if args[:jokers]
end

Instance Attribute Details

#cardsObject

The cards in the deck



4
5
6
# File 'lib/deck.rb', line 4

def cards
  @cards
end