Class: Pidgin2Adium::Message
- Inherits:
-
Object
- Object
- Pidgin2Adium::Message
- Includes:
- Comparable
- Defined in:
- lib/pidgin2adium/messages/message.rb
Overview
A holding object for each line of the chat. It is subclassed as appropriate (eg AutoReplyMessage). Each subclass (but not Message itself) has its own to_s which prints out its information in a format appropriate for putting in an Adium log file. Subclasses: XMLMessage, AutoReplyMessage, StatusMessage, Event.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#buddy_alias ⇒ Object
Returns the value of attribute buddy_alias.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#<=>(other_message) ⇒ Object
Compare this Message to
other_message
, based on their timestamps. -
#initialize(sender, time, buddy_alias) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(sender, time, buddy_alias) ⇒ Message
Returns a new instance of Message.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pidgin2adium/messages/message.rb', line 12 def initialize(sender, time, buddy_alias) # The sender's screen name @sender = sender # The time the message was sent, in Adium format (e.g. # "2008-10-05T22:26:20-0800") @time = time @time_object = Time.parse(@time) # The receiver's alias (NOT screen name) @buddy_alias = buddy_alias end |
Instance Attribute Details
#buddy_alias ⇒ Object
Returns the value of attribute buddy_alias.
22 23 24 |
# File 'lib/pidgin2adium/messages/message.rb', line 22 def buddy_alias @buddy_alias end |
#sender ⇒ Object
Returns the value of attribute sender.
22 23 24 |
# File 'lib/pidgin2adium/messages/message.rb', line 22 def sender @sender end |
#time ⇒ Object
Returns the value of attribute time.
22 23 24 |
# File 'lib/pidgin2adium/messages/message.rb', line 22 def time @time end |
Instance Method Details
#<=>(other_message) ⇒ Object
Compare this Message to other_message
, based on their timestamps. Returns a number < 0 if this message was sent before other_message
, 0 if they were sent at the same time, and a number > 0 if this message was sent after other_message
.
28 29 30 |
# File 'lib/pidgin2adium/messages/message.rb', line 28 def <=>() return @time_object - .time_object end |