Class: IRC::Messages::Message
- Inherits:
-
Object
- Object
- IRC::Messages::Message
- Includes:
- Codes
- Defined in:
- lib/irc/messages/message.rb
Direct Known Subclasses
ErrorAlreadyRegisteredMessage, ErrorErroneusNickNameMessage, ErrorJoinMessage, ErrorMessage, ErrorNeedMoreParametersMessage, ErrorNickCollisionMessage, ErrorNickNameInUseMessage, ErrorNoNickNameGivenMessage, ErrorNoOriginMessage, ErrorNoSuchServerMessage, ErrorNotOnChannelMessage, ISupportMessage, JoinMessage, KickMessage, NickMessage, NoticeMessage, PartMessage, PingMessage, PongMessage, PrivateMessage, WelcomeMessage
Constant Summary collapse
- MESSAGE_FORMAT =
Regexp.new('(:([^!\s]+)(!([^@\s]+))?(@(\S+))?\s+)?(\w+|\d\d\d)\s*(.*)')
Constants included from Codes
Codes::ERR_ALREADYREGISTRED, Codes::ERR_BADCHANMASK, Codes::ERR_BADCHANNAME, Codes::ERR_BADCHANNELKEY, Codes::ERR_BANNEDFROMCHAN, Codes::ERR_CANNOTSENDTOCHAN, Codes::ERR_CANTKILLSERVER, Codes::ERR_CHANNELISFULL, Codes::ERR_CHANOPRIVSNEEDED, Codes::ERR_ERRONEUSNICKNAME, Codes::ERR_FILEERROR, Codes::ERR_INVALIDUSERNAME, Codes::ERR_INVITEONLYCHAN, Codes::ERR_KEYSET, Codes::ERR_LINKCHANNEL, Codes::ERR_NEEDMOREPARAMS, Codes::ERR_NICKCOLLISION, Codes::ERR_NICKNAMEINUSE, Codes::ERR_NOADMININFO, Codes::ERR_NOLOGIN, Codes::ERR_NOMOTD, Codes::ERR_NONICKNAMEGIVEN, Codes::ERR_NOOPERHOST, Codes::ERR_NOORIGIN, Codes::ERR_NOPERMFORHOST, Codes::ERR_NOPRIVILEGES, Codes::ERR_NORECIPIENT, Codes::ERR_NOSERVICEHOST, Codes::ERR_NOSUCHCHANNEL, Codes::ERR_NOSUCHNICK, Codes::ERR_NOSUCHSERVER, Codes::ERR_NOTEXTTOSEND, Codes::ERR_NOTONCHANNEL, Codes::ERR_NOTOPLEVEL, Codes::ERR_NOTREGISTERED, Codes::ERR_PASSWDMISMATCH, Codes::ERR_SECUREONLYCHAN, Codes::ERR_SUMMONDISABLED, Codes::ERR_TARGETTOOFAST, Codes::ERR_TOOMANYCHANNELS, Codes::ERR_TOOMANYTARGETS, Codes::ERR_UMODEUNKNOWNFLAG, Codes::ERR_UNKNOWNCOMMAND, Codes::ERR_UNKNOWNMODE, Codes::ERR_USERNOTINCHANNEL, Codes::ERR_USERONCHANNEL, Codes::ERR_USERSDISABLED, Codes::ERR_USERSDONTMATCH, Codes::ERR_WASNOSUCHNICK, Codes::ERR_WILDTOPLEVEL, Codes::ERR_YOUREBANNEDCREEP, Codes::ERR_YOUWILLBEBANNED, Codes::RPL_ADMINEMAIL, Codes::RPL_ADMINLOC1, Codes::RPL_ADMINLOC2, Codes::RPL_ADMINME, Codes::RPL_AWAY, Codes::RPL_BANLIST, Codes::RPL_BOUNCE, Codes::RPL_CHANNELMODEIS, Codes::RPL_CLOSEEND, Codes::RPL_CLOSING, Codes::RPL_CREATED, Codes::RPL_ENDOFBANLIST, Codes::RPL_ENDOFINFO, Codes::RPL_ENDOFLINKS, Codes::RPL_ENDOFMOTD, Codes::RPL_ENDOFNAMES, Codes::RPL_ENDOFSERVICES, Codes::RPL_ENDOFSTATS, Codes::RPL_ENDOFUSERS, Codes::RPL_ENDOFWHO, Codes::RPL_ENDOFWHOIS, Codes::RPL_ENDOFWHOWAS, Codes::RPL_INFO, Codes::RPL_INFOSTART, Codes::RPL_INVITING, Codes::RPL_ISON, Codes::RPL_ISUPPORT, Codes::RPL_KILLDONE, Codes::RPL_LINKS, Codes::RPL_LIST, Codes::RPL_LISTEND, Codes::RPL_LISTSTART, Codes::RPL_LUSERCHANNELS, Codes::RPL_LUSERCLIENT, Codes::RPL_LUSERME, Codes::RPL_LUSEROP, Codes::RPL_LUSERUNKNOWN, Codes::RPL_MOTD, Codes::RPL_MOTDSTART, Codes::RPL_MYINFO, Codes::RPL_MYPORTIS, Codes::RPL_NAMREPLY, Codes::RPL_NONE, Codes::RPL_NOTOPIC, Codes::RPL_NOUSERS, Codes::RPL_NOWAWAY, Codes::RPL_REHASHING, Codes::RPL_SERVICE, Codes::RPL_SERVICEINFO, Codes::RPL_SERVLIST, Codes::RPL_SERVLISTEND, Codes::RPL_STATSCLINE, Codes::RPL_STATSCOMMANDS, Codes::RPL_STATSHLINE, Codes::RPL_STATSILINE, Codes::RPL_STATSKLINE, Codes::RPL_STATSLINKINFO, Codes::RPL_STATSLLINE, Codes::RPL_STATSNLINE, Codes::RPL_STATSOLINE, Codes::RPL_STATSQLINE, Codes::RPL_STATSUPTIME, Codes::RPL_STATSYLINE, Codes::RPL_SUMMONING, Codes::RPL_TIME, Codes::RPL_TOPIC, Codes::RPL_TOPICINFO, Codes::RPL_TRACECLASS, Codes::RPL_TRACECONNECTING, Codes::RPL_TRACEHANDSHAKE, Codes::RPL_TRACELINK, Codes::RPL_TRACELOG, Codes::RPL_TRACENEWTYPE, Codes::RPL_TRACEOPERATOR, Codes::RPL_TRACESERVER, Codes::RPL_TRACEUNKNOWN, Codes::RPL_TRACEUSER, Codes::RPL_UMODEIS, Codes::RPL_UNAWAY, Codes::RPL_USERHOST, Codes::RPL_USERS, Codes::RPL_USERSSTART, Codes::RPL_VERSION, Codes::RPL_WELCOME, Codes::RPL_WHOISCHANNELS, Codes::RPL_WHOISCHANOP, Codes::RPL_WHOISIDLE, Codes::RPL_WHOISOPERATOR, Codes::RPL_WHOISSERVER, Codes::RPL_WHOISUSER, Codes::RPL_WHOREPLY, Codes::RPL_WHOWASUSER, Codes::RPL_YOUREOPER, Codes::RPL_YOURHOST
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#nick ⇒ Object
readonly
Returns the value of attribute nick.
-
#raw_message ⇒ Object
readonly
Returns the value of attribute raw_message.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Class Method Summary collapse
-
.is_valid?(raw_message) ⇒ Boolean
Returns true if the given string matches the IRC message format, else false.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#eql?(other) ⇒ Boolean
Returns true if the other Message object is equal to the current.
-
#handle(context) ⇒ Object
Notify all connection listeners that a message was received from the IRC server, by calling their on_server_response method.
-
#initialize(raw_message) ⇒ Message
constructor
A new instance of Message.
- #to_s ⇒ Object
Constructor Details
#initialize(raw_message) ⇒ Message
Returns a new instance of Message.
48 49 50 |
# File 'lib/irc/messages/message.rb', line 48 def initialize() parse() end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
40 41 42 |
# File 'lib/irc/messages/message.rb', line 40 def code @code end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
41 42 43 |
# File 'lib/irc/messages/message.rb', line 41 def host @host end |
#login ⇒ Object (readonly)
Returns the value of attribute login.
46 47 48 |
# File 'lib/irc/messages/message.rb', line 46 def login @login end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
42 43 44 |
# File 'lib/irc/messages/message.rb', line 42 def @message end |
#nick ⇒ Object (readonly)
Returns the value of attribute nick.
43 44 45 |
# File 'lib/irc/messages/message.rb', line 43 def nick @nick end |
#raw_message ⇒ Object (readonly)
Returns the value of attribute raw_message.
44 45 46 |
# File 'lib/irc/messages/message.rb', line 44 def @raw_message end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
45 46 47 |
# File 'lib/irc/messages/message.rb', line 45 def server @server end |
Class Method Details
.is_valid?(raw_message) ⇒ Boolean
Returns true if the given string matches the IRC message format, else false.
80 81 82 |
# File 'lib/irc/messages/message.rb', line 80 def self.is_valid?() return Regexp.new(MESSAGE_FORMAT).match() != nil end |
Instance Method Details
#==(other) ⇒ Object
52 53 54 |
# File 'lib/irc/messages/message.rb', line 52 def ==(other) return eql?(other) end |
#eql?(other) ⇒ Boolean
Returns true if the other Message object is equal to the current.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/irc/messages/message.rb', line 57 def eql?(other) return false if !other.kind_of?(Message) return false if code != other.code return false if host != other.host return false if != other. return false if != other. return false if server != other.server return false if login != other.login return true end |
#handle(context) ⇒ Object
Notify all connection listeners that a message was received from the IRC server, by calling their on_server_response method.
70 71 72 73 74 75 76 77 |
# File 'lib/irc/messages/message.rb', line 70 def handle(context) # Notify all connection listeners by calling their on_server_response method. notify(context) do |connection_listener| connection_listener.on_server_response(context, self) end end |
#to_s ⇒ Object
84 85 86 |
# File 'lib/irc/messages/message.rb', line 84 def to_s return end |