Class: IRC::Message
- Inherits:
-
Object
- Object
- IRC::Message
- Defined in:
- lib/irc/message.rb
Constant Summary collapse
- REGEX =
/^ (: (?<prefix> ( (?<servername>(?<nick>[a-z][a-z0-9_\-\[\]\\`\^\{\}\.\|]*)) ) (!(?<user>[a-z0-9~\.]+))? (@(?<host>[a-z0-9\.]+))? ) [\ ]+ )? (?<command>[a-z]+|[0-9]{3}) (?<params> (\ +(?<middle>[^:\r\n\ ][^\r\n\ ]*))* (\ *:(?<trailing>.+))? ) \r\n$ /xi
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #action ⇒ Object
- #content ⇒ Object
-
#initialize(message_string, connection) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(message_string, connection) ⇒ Message
Returns a new instance of Message.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/irc/message.rb', line 26 def initialize , connection @raw = @connection = connection @match = REGEX.match() || {} REGEX.names.each do |name| instance_variable_set("@#{name}", @match[name]) end end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
23 24 25 |
# File 'lib/irc/message.rb', line 23 def connection @connection end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
22 23 24 |
# File 'lib/irc/message.rb', line 22 def raw @raw end |
Instance Method Details
#action ⇒ Object
38 39 40 |
# File 'lib/irc/message.rb', line 38 def action @action ||= (command || '').downcase.intern end |
#content ⇒ Object
42 43 44 |
# File 'lib/irc/message.rb', line 42 def content @content ||= trailing || middle end |