Created
March 6, 2019 11:05
-
-
Save vestige/0936d86b4beadd2a691f255cd392e88b 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 Responder | |
def initialize(name) | |
@name = name | |
end | |
def response(input) | |
return '' | |
end | |
def name | |
return @name | |
end | |
end | |
class WhatResponder < Responder | |
def response(input) | |
return "#{input}ってなに?" | |
end | |
end | |
class RandomResponder < Responder | |
def initialize(name) | |
super | |
@phrases = [] | |
open('./dic/rand.txt') do |f| | |
f.each do |line| | |
line.chomp! | |
next if line.empty? | |
@phrases.push(line) | |
end | |
end | |
#@responses = ['今日はサム', 'ちょこー', 'おかねー'] | |
end | |
def response(input) | |
return select_random(@phrases) | |
end | |
def select_random(ary) | |
return ary.sample | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment