Class: Skypescraper::Conversation
- Inherits:
-
Object
- Object
- Skypescraper::Conversation
- Defined in:
- lib/skypescraper/conversation.rb
Constant Summary collapse
- PARTICIPANTS_QUERY =
<<-SQL SELECT p.identity AS identity, COALESCE(c.fullname, c.displayname, c.skypename, c.pstnnumber, '') AS name FROM participants AS p LEFT JOIN contacts AS c ON p.identity = c.skypename WHERE p.convo_id = ? ORDER BY name COLLATE NOCASE SQL
- MESSAGES_QUERY =
type = 61 is the ordinary message
<<-SQL SELECT m.author AS identity, m.body_xml AS text, m.type AS m_type, m.timestamp AS created_at FROM messages AS m WHERE m.convo_id = ? AND m.type = 61 ORDER BY timestamp SQL
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(id, title) ⇒ Conversation
constructor
A new instance of Conversation.
- #messages ⇒ Object
- #participants ⇒ Object
Constructor Details
#initialize(id, title) ⇒ Conversation
Returns a new instance of Conversation.
7 8 9 10 |
# File 'lib/skypescraper/conversation.rb', line 7 def initialize(id, title) @id = id @title = title end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/skypescraper/conversation.rb', line 5 def id @id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/skypescraper/conversation.rb', line 5 def title @title end |
Instance Method Details
#messages ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/skypescraper/conversation.rb', line 39 def return @messages if @messages @messages = [] Skypescraper::Extractor.connection.execute(MESSAGES_QUERY, id) do |row| << Skypescraper::Message.new(*row) end @messages end |
#participants ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/skypescraper/conversation.rb', line 20 def participants return @participants if @participants @participants = [] Skypescraper::Extractor.connection.execute(PARTICIPANTS_QUERY, id) do |row| @participants << Skypescraper::Contact.new(*row) end @participants end |