class Object

Public Instance Methods

card_test(card, actual_value) click to toggle source

@param card [CardDeck::Card] @param actual_value [Integer] @return [Integer] @note Used by the CPU to determine which card to play. Parameter card needs to be an instance of Card.

end

# File lib/99_game.rb, line 10
def card_test(card, actual_value)
        test_value = case card.num
                when "King" then 99
                when "Joker" then 0
        else
                actual_value + card.value
       end
       test_value = -1 if test_value > 99
        test_value
end
converter(input) click to toggle source

@param input [String] @return [String, Integer] If parameter input is an abbreviation, input is converted to what it stands for. Otherwise, it simply returns a capitalized version of input. @raise [CardError] if input is nil or an emtpy string

end

# File lib/99_game.rb, line 43
def converter(input)
        abbrev = {"$" => "Joker", "K" => "King", "J" => "Jack", "Q" => "Queen", "A" => "Ace"}
        raise(CardError, "Input cannot be blank") if input == String.new
        if input.to_i.zero?
                case input.capitalize
                        when ?$, "Joker" then "Joker"
                        when ?K, "King" then "King"
                        when ?J, "Jack" then "Jack"
                        when ?Q, "Queen" then "Queen"
                        when ?A, "Ace" then "Ace"
                end
        else
                input.to_i
        end
end
not_nil?(obj) click to toggle source

Tests if obj is not nil.

# File lib/99_game.rb, line 21
def not_nil?(obj)
        !obj.nil?
end
pause(p) click to toggle source

Combines sleep and a newline @param p [Integer] amount of time to sleep @return [void]

end

# File lib/99_game.rb, line 32
def pause(p)
        sleep p
        puts
end