Class: Skypescraper::Extractor
- Inherits:
-
Object
- Object
- Skypescraper::Extractor
- Defined in:
- lib/skypescraper/extractor.rb
Constant Summary collapse
- CONVERSATIONS_SQL =
<<-SQL SELECT id, COALESCE(displayname, meta_topic, identity) AS title FROM conversations WHERE id IN ( SELECT DISTINCT(convo_id) FROM participants WHERE identity = ? ) ORDER BY last_activity_timestamp DESC SQL
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
- #conversations_for(identity) ⇒ Object
-
#initialize(database) ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
#initialize(database) ⇒ Extractor
Returns a new instance of Extractor.
18 19 20 |
# File 'lib/skypescraper/extractor.rb', line 18 def initialize(database) self.class.connection = SQLite3::Database.new(database) end |
Class Method Details
.connection ⇒ Object
12 13 14 15 |
# File 'lib/skypescraper/extractor.rb', line 12 def connection raise 'You must establish a connection by calling Skypescraper::Extractor.new first' unless @db @db end |
.connection=(db) ⇒ Object
8 9 10 |
# File 'lib/skypescraper/extractor.rb', line 8 def connection=(db) @db = db end |
Instance Method Details
#connection ⇒ Object
22 23 24 |
# File 'lib/skypescraper/extractor.rb', line 22 def connection self.class.connection end |
#conversations_for(identity) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/skypescraper/extractor.rb', line 36 def conversations_for(identity) return @conversations[identity] if @conversations && @conversations[identity] @conversations ||= {} @conversations[identity] = [] connection.execute(CONVERSATIONS_SQL, identity) do |row| @conversations[identity] << Skypescraper::Conversation.new(*row) end @conversations[identity] end |