Top Level Namespace
Defined Under Namespace
Classes: Card, CardError, Hand
Instance Method Summary collapse
-
#converter(input) ⇒ Object
Converts input to an integer if String#capitalize does something.
-
#not_nil?(obj) ⇒ Boolean
Tests if obj is not nil.
-
#pause(p) ⇒ Object
Combines sleep and a newline.
Instance Method Details
#converter(input) ⇒ Object
Converts input to an integer if String#capitalize does something. If input is an abbreviation, input is converted to what it stands for. Otherwise, it simply returns a capitalized version of input. If input is nil or an emtpy string, raises a CardError
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/99_game.rb', line 10 def converter(input) abbrev = {"$".to_sym => "Joker", K: "King", J: "Jack", Q: "Queen", A: "Ace"} if input == input.capitalize return input.to_i elsif not_nil? abbrev[input.capitalize.to_sym] return abbrev[input.capitalize.to_sym] elsif input.nil || input == String.new raise CardError, "Input not allowed" else return input.capitalize end end |
#not_nil?(obj) ⇒ Boolean
Tests if obj is not nil.
2 3 4 5 6 7 8 |
# File 'lib/99_game.rb', line 2 def not_nil?(obj) if obj.nil return false else return true end end |
#pause(p) ⇒ Object
Combines sleep and a newline.
79 80 81 82 |
# File 'lib/99_game.rb', line 79 def pause(p) sleep p puts end |