Module: IMExporter::Contact
- Defined in:
- lib/im_exporter/contact.rb
Overview
A module to handle contact lists from the iMessage sqlite database
Class Method Summary collapse
-
.contact_ids ⇒ Object
returns all contact IDs within the iMessage sqlitedb.
-
.name(id, phone) ⇒ Object
returns the name of the contact with the specified ID and Phone number.
-
.parse_contact_name_from_string(row) ⇒ Object
returns a contact name from a string that includes the contact’s name and phone number.
Class Method Details
.contact_ids ⇒ Object
returns all contact IDs within the iMessage sqlitedb
24 25 26 |
# File 'lib/im_exporter/contact.rb', line 24 def self.contact_ids $chat_db.execute('select ROWID, id from handle') end |
.name(id, phone) ⇒ Object
returns the name of the contact with the specified ID and Phone number
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/im_exporter/contact.rb', line 11 def self.name(id, phone) name = id query = 'select ZSTRINGFORINDEXING from ZABCDCONTACTINDEX' $user_db.execute(query) do |contact| row = contact.join('').split(' ') contact_name = self.parse_contact_name_from_string(row) contact_phone = row.last if contact_phone.eql? phone then name = contact_name end end name end |
.parse_contact_name_from_string(row) ⇒ Object
returns a contact name from a string that includes the contact’s name and phone number
6 7 8 |
# File 'lib/im_exporter/contact.rb', line 6 def self.parse_contact_name_from_string(row) row.select { |element| row.count(element) > 1 }.uniq.select { |string| string[/[a-zA-Z]/] }.join(' ') end |