Created
January 7, 2013 01:56
-
-
Save qizwiz/4471676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We want to make sure that each game is a valid game object - in this case a simple hash of values. Even still, we wouldn't want to return a hash with a nil name. Raise an InvalidGameError error in the new_game method if name is nil. | |
class InvalidGameError < StandardError; end | |
def new_game(name, options={}) | |
{ | |
name: name, | |
year: options[:year], | |
system: options[:system] | |
} | |
end | |
begin | |
game = new_game(nil) | |
rescue InvalidGameError => e | |
puts "There was a problem creating your new game: #{e.message}" | |
end |
ghost
commented
Nov 22, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment