Class: Pidgin2Adium::Message

Inherits:
Object
  • Object
show all
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

StatusMessage, XMLMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

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_aliasObject

Returns the value of attribute buddy_alias.



22
23
24
# File 'lib/pidgin2adium/messages/message.rb', line 22

def buddy_alias
  @buddy_alias
end

#senderObject

Returns the value of attribute sender.



22
23
24
# File 'lib/pidgin2adium/messages/message.rb', line 22

def sender
  @sender
end

#timeObject

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 <=>(other_message)
  return @time_object - other_message.time_object
end