WindowsのCygwinにて取り組んでいるのですが、以下のコードにてエラーが発生します。
何を言われているのかはなんとなくわかるのですが、うまく直せません。
アドバイスお願いします。
#! ruby -Ks
# coding: utf-8
class Responder
def initialize(name)
@name = name
end
def response(input)
return "#{input}って何?"
end
def name
return (@name)
end
end
class Unmo
def initialize(name)
@name = name
@responder = Responder.new("What")
end
def dialogue(input)
return (@responder.response(input)
end
def responder_name
return (@responder.name)
end
def name
return (@name)
end
end
def prompt(unmo)
return unmo.name + ':' + unmo.responder_name + '>'
end
puts "Unmo System prototype : proto"
proto = Unmo.new("proto")
while true
print "> "
input = gets
input.chomp!
break if input == ""
response = proto.dialogue(input)
puts(prompt(proto) + response)
end
$ ruby proto.rb
Unmo System prototype : proto
> おっす
proto.rb:11:in `response': incompatible character encodings: Windows-31J and UTF-8 (Encoding::CompatibilityError)
from proto.rb:26:in `dialogue'
from proto.rb:50:in `<main>'
ちなみに試した方法は を とする事です。