class Skypescraper::Extractor

Constants

CONVERSATIONS_SQL

Public Class Methods

connection() click to toggle source
# 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) click to toggle source
# File lib/skypescraper/extractor.rb, line 8
def connection=(db)
  @db = db
end
new(database) click to toggle source
# File lib/skypescraper/extractor.rb, line 18
def initialize(database)
  self.class.connection = SQLite3::Database.new(database)
end

Public Instance Methods

connection() click to toggle source
# File lib/skypescraper/extractor.rb, line 22
def connection
  self.class.connection
end
conversations_for(identity) click to toggle source
# 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