Class: Raibo::IrcMessage
- Inherits:
-
Object
- Object
- Raibo::IrcMessage
- Defined in:
- lib/raibo/message.rb
Instance Attribute Summary collapse
-
#middle ⇒ Object
readonly
Returns the value of attribute middle.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#trailing ⇒ Object
readonly
Returns the value of attribute trailing.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #body ⇒ Object
- #from ⇒ Object
-
#initialize(line) ⇒ IrcMessage
constructor
A new instance of IrcMessage.
- #kind ⇒ Object
- #to ⇒ Object
Constructor Details
#initialize(line) ⇒ IrcMessage
Returns a new instance of IrcMessage.
13 14 15 |
# File 'lib/raibo/message.rb', line 13 def initialize(line) @prefix, @type, @middle, @trailing = parse_line(line) end |
Instance Attribute Details
#middle ⇒ Object (readonly)
Returns the value of attribute middle.
11 12 13 |
# File 'lib/raibo/message.rb', line 11 def middle @middle end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
11 12 13 |
# File 'lib/raibo/message.rb', line 11 def prefix @prefix end |
#trailing ⇒ Object (readonly)
Returns the value of attribute trailing.
11 12 13 |
# File 'lib/raibo/message.rb', line 11 def trailing @trailing end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/raibo/message.rb', line 11 def type @type end |
Instance Method Details
#body ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/raibo/message.rb', line 42 def body case kind when :message trailing when :emote trailing[/\001ACTION ([^\001]*)/, 1] end end |
#from ⇒ Object
32 33 34 |
# File 'lib/raibo/message.rb', line 32 def from prefix[/^([^!@ ]*)/, 1] end |
#kind ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/raibo/message.rb', line 17 def kind case type when 'PRIVMSG' if trailing =~ /^\001ACTION/ :emote else :message end when 'JOIN' :join when 'PART' :part end end |
#to ⇒ Object
36 37 38 39 40 |
# File 'lib/raibo/message.rb', line 36 def to if [:message, :emote].include?(kind) middle.first end end |