如何在 ruby 模块上使用方法拆分?

How can I use method split on ruby module?

大家好尝试在模块中使用拆分方法但我不能,终端给我这个错误:undefined method `split' for :"set algo":Symbol (NoMethodError)

class Server
    def initialize(port,ip)
      @server = TCPServer.open(ip,port)
      @connections = Hash.new
      @clients = Hash.new
      @connections[:server] = @server
      @connections[:clients] = @clients
      run
      split
    end

  def run
    loop{
      Thread.start(@server.accept) do | client |
        # for each user connected and accepted by server, it will create a new thread object
        # and which pass the connected client as an instance to the block
        request = client.gets.chomp.to_sym
        dev =  request.split(" ")
        client.puts dev[0]
         #if dev[0] ==  "set"
          #  client.puts "OPERACION VALIDA"
         #else
          #  client.puts "OPERACION INVALIDA "
          #  Thread.kill self
        #end
      end
    }.join
  end



end
 Server.new(3000, "localhost")

替换:

request = client.gets.chomp.to_sym

与:

request = client.gets.chomp

调用 to_sym 将字符串从 gets/chomp 转换为未实现 split.

的符号