Module: IM_Exporter::Contact

Defined in:
lib/im_exporter/contact.rb

Class Method Summary collapse

Class Method Details

.get_contact_idsObject



20
21
22
# File 'lib/im_exporter/contact.rb', line 20

def self.get_contact_ids
  return $chat_db.execute('select ROWID, id from handle')
end

.name(id, phone) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/im_exporter/contact.rb', line 7

def self.name(id, phone)
  name = id
  $user_db.execute('select ZSTRINGFORINDEXING from ZABCDCONTACTINDEX') do |contact|
    row = contact.join('').split(' ')
    contact_name = self.parse_contact_name_from_string(row)
    contact_phone = row.last
    if contact_phone.eql? phone
      name = contact_name
    end
  end
  return name
end

.parse_contact_name_from_string(row) ⇒ Object



3
4
5
# File 'lib/im_exporter/contact.rb', line 3

def self.parse_contact_name_from_string(row)
  return row.select{|element| row.count(element) > 1 }.uniq.select{ |i| i[/[a-zA-Z]/] }.join(' ')
end