我在一个文件中维护了一些类来运行deamon进程。但我得到了lib/web_socket.rb:4:in <top (required)>: WebSocket is not a class (TypeError)
错误
我已经配置了像这样的文件
require 'rubygems'
require 'daemons'
require_relative 'lib/web_socket.rb'
require_relative 'app/models/global'
lib-web_socket.rb是
require "socket"
require 'libwebsocket'
class WebSocket
end
Websocket是一个模块
irb(main):001:0> module Websocket
irb(main):002:1> end
=> nil
irb(main):003:0> class Websocket
irb(main):004:1> end
TypeError: Websocket is not a class
from (irb):3
from /home/nicco/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'
要么写module WebSocket
,要么写
module MyModule
class WebSocket
include ::WebSocket
end
end
或者这可能是你的情况
class MyWebSocket
include WebSocket
end