Module: IMExporter::Attachment

Defined in:
lib/im_exporter/attachment.rb

Overview

A module to handle attachments from the iMessage sqlite database

Class Method Summary collapse

Class Method Details

.supported_file_type?(file) ⇒ Boolean

checks whether the attachment is supported by prawn

Returns:

  • (Boolean)


19
20
21
# File 'lib/im_exporter/attachment.rb', line 19

def self.supported_file_type?(file)
  if file.include?('JPG') || file.include?('PNG') then true else false end
end

.write(attachment_id) ⇒ Object

writes attachments (images) out to a PDF or TXT file



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

def self.write(attachment_id)
  query = 'select a.filename from attachment as a join message as m on m.date = a.created_date where m.rowid=?'
  $chat_db.execute(query, attachment_id) do |file_dir|
    file = file_dir.join('').sub!('~', '/Users/benvisser')
    if self.supported_file_type?(file)
      $pdf.image file, height: 250
    else
      $pdf.text '[IMAGE-TYPE NOT SUPPORTED]'
    end
  end
end