class GemDeck

Attributes

cards[RW]

Public Class Methods

new(initial_card) click to toggle source
# File lib/cards_on_deck/gem_deck.rb, line 4
def initialize(initial_card)
    @cards = [initial_card]
end

Public Instance Methods

add(new_cards) click to toggle source
# File lib/cards_on_deck/gem_deck.rb, line 8
def add(new_cards)
    @cards.concat(new_cards)
end
create(type = 'Standard') click to toggle source
# File lib/cards_on_deck/gem_deck.rb, line 20
def create(type = 'Standard')
    @cards = []
    standard_deck = []

    if type == 'Standard'
        standard_values.each do |k, array|
            array.each do |value|
                standard_deck <<  GemCard.new(k.to_s, value)
            end
        end
    end

    add(standard_deck)
end
draw(location = nil) click to toggle source
# File lib/cards_on_deck/gem_deck.rb, line 12
def draw(location = nil)
    location == nil ? @cards.slice!(@cards.count / 2) : @cards.slice!(location - 1)
end
shuffle() click to toggle source
# File lib/cards_on_deck/gem_deck.rb, line 16
def shuffle
    @cards.shuffle!
end

Private Instance Methods

standard_values() click to toggle source
# File lib/cards_on_deck/gem_deck.rb, line 37
def standard_values
    values = [
        "Ace", "King", "Queen", "Jack", "Ten", "Nine", "Eight", "Seven", "Six",
        "Five", "Four", "Three", "Two"
    ]

    {
        'Hearts': values,
        'Diamonds': values,
        'Spades': values,
        'Clubs': values,
    }
end