Class: IRC::Message
- Inherits:
-
Object
- Object
- IRC::Message
- Defined in:
- lib/irc/message.rb
Constant Summary collapse
- REGEX =
/^ (: (?<prefix> ( (?<servername>(?<nick>[a-z#{special_characters}][a-z0-9#{special_characters}]*)) ) (!(?<user>[a-z0-9~\.]+))? (@(?<host>[a-z0-9\.\-_]{1,255}))? ) [\ ]+ )? (?<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 = nil) ⇒ Message
constructor
A new instance of Message.
- #target ⇒ Object
Constructor Details
#initialize(message_string, connection = nil) ⇒ Message
Returns a new instance of Message.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/irc/message.rb', line 27 def initialize , connection = nil @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.
24 25 26 |
# File 'lib/irc/message.rb', line 24 def connection @connection end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
23 24 25 |
# File 'lib/irc/message.rb', line 23 def raw @raw end |
Instance Method Details
#action ⇒ Object
39 40 41 |
# File 'lib/irc/message.rb', line 39 def action @action ||= (command || '').downcase.intern end |
#content ⇒ Object
47 48 49 |
# File 'lib/irc/message.rb', line 47 def content @content ||= trailing || middle end |
#target ⇒ Object
43 44 45 |
# File 'lib/irc/message.rb', line 43 def target middle end |