class SwordFightInsults
Public Instance Methods
output()
click to toggle source
# File lib/swordfightinsults.rb, line 17 def output() msg = read_random_message() puts split_insult_comeback(msg) end
read_random_message()
click to toggle source
# File lib/swordfightinsults.rb, line 5 def read_random_message() lines = IO.readlines("messages.txt") random_line = Random.new().rand(1...lines.size()) return lines[random_line] end
split_insult_comeback(msg)
click to toggle source
# File lib/swordfightinsults.rb, line 11 def split_insult_comeback(msg) matches = msg.match(/Insult:(.*)Comeback:(.*)/) puts "\nGuybrush: #{matches[1]}" puts "Pirate Master: #{matches[2]}\n" end