Class: Dragoon::Event
- Inherits:
-
Object
- Object
- Dragoon::Event
- Defined in:
- lib/dragoon/event.rb
Defined Under Namespace
Classes: Message
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, message) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(name, message) ⇒ Event
Returns a new instance of Event.
9 10 11 12 |
# File 'lib/dragoon/event.rb', line 9 def initialize(name, ) @name = name @message = end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/dragoon/event.rb', line 7 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/dragoon/event.rb', line 7 def name @name end |
Class Method Details
.parse(line) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dragoon/event.rb', line 14 def self.parse(line) case line when /^:\S+ NOTICE .*:\*{3} .*/ self.new(:startup, Message.new(:text => line)) when /^PING :(\S+)/ self.new(:ping, Message.new(:text => line, :server => $1)) when /^:\S+ 001 (\S+) :.*/ self.new(:welcome, Message.new(:text => line, :nickname => $1)) when /^:(\S+)!(\S+)@(\S+) JOIN (\S+)/ self.new(:join, Message.new(:text => line, :nickname => $1, :user => $2, :hostname => $3, :channel => $4)) when /^:(\S+)!(\S+)@(\S+) PRIVMSG (\S+) :(.+)/ self.new(:privmsg, Message.new(:text => line, :nickname => $1, :user => $2, :hostname => $3, :receiver => Receiver.new($4), :privmsg => $5)) when /^:\S+ (4\d{2}|5\d{2}) .*/ self.new(:err, Message.new(:text => line, :error_code => $1)) else self.new(:unknown, Message.new(:text => line)) end end |