Module: IM_Exporter::Attachment

Defined in:
lib/im_exporter/attachment.rb

Class Method Summary collapse

Class Method Details

.supported_file_type?(file) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/im_exporter/attachment.rb', line 14

def self.supported_file_type?(file)
  (file.include? "JPG" or file.include? "PNG") ? true : false
end

.write(attachment_id) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/im_exporter/attachment.rb', line 3

def self.write(attachment_id)
  $chat_db.execute('select a.filename from attachment as a join message as m on m.date = a.created_date where m.rowid=?', 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