Class: IRConnect::Command
- Inherits:
-
Object
- Object
- IRConnect::Command
- Defined in:
- lib/command.rb
Overview
represents an IRC Command received from the server
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#last_param ⇒ Object
readonly
Returns the value of attribute last_param.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(command_string) ⇒ Command
constructor
IRC message format: :<prefix> <command> <params> :<trailing> info on parsing commands: goo.gl/N3YGLq.
Constructor Details
#initialize(command_string) ⇒ Command
IRC message format: :<prefix> <command> <params> :<trailing> info on parsing commands: goo.gl/N3YGLq
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/command.rb', line 10 def initialize(command_string) fail 'Bad IRC command format' unless command_string =~ / \A (?::([^\040]+)\040)? # prefix ([A-Za-z]+|\d{3}) # command ((?:\040[^:][^\040]+)*) # all but the last param (?:\040:?(.*))? # last param \Z /x @prefix, @command = Regexp.last_match(1), Regexp.last_match(2) parse_params(Regexp.last_match(3), Regexp.last_match(4)) end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/command.rb', line 4 def command @command end |
#last_param ⇒ Object (readonly)
Returns the value of attribute last_param.
4 5 6 |
# File 'lib/command.rb', line 4 def last_param @last_param end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/command.rb', line 4 def params @params end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
4 5 6 |
# File 'lib/command.rb', line 4 def prefix @prefix end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 25 26 |
# File 'lib/command.rb', line 22 def ==(other) prefix == other.prefix && command == other.command && params == other.params end |