Class: RubyPlayingCards::Deck

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

Constant Summary collapse

SUITS =
[
  { name: :spades,    icon: :

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeck

Returns a new instance of Deck.



11
12
13
14
# File 'lib/ruby_playing_cards/deck.rb', line 11

def initialize
  @cards = []
  build_deck
end

Instance Attribute Details

#cardsObject

Returns the value of attribute cards.



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

def cards
  @cards
end

Instance Method Details

#sizeObject



16
17
18
# File 'lib/ruby_playing_cards/deck.rb', line 16

def size
  @cards.size
end

#to_sObject



20
21
22
23
24
# File 'lib/ruby_playing_cards/deck.rb', line 20

def to_s
  @cards.map do |card|
    "#{card.suit}#{card.rank}"
  end
end