-
-
Save videlais/2a8dc0930483ddd4e6eb 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
class Parser | |
def initalize() | |
end | |
public | |
def parse(input) | |
case input | |
when "go" | |
go_response | |
when "get" | |
get_response | |
when "put" | |
put_response | |
else | |
bad_response | |
end | |
end | |
private | |
def go_response | |
puts "Where would you like to go?" | |
end | |
def get_response | |
puts "Get what?" | |
end | |
def put_response | |
puts "Put what, exactly?" | |
end | |
def bad_response | |
puts "I don't know about that." | |
end | |
end | |
parser = Parser.new | |
loop do | |
puts ":" | |
input = gets.chomp | |
input.downcase! | |
break if input == "quit" | |
parser.parse(input) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment