Module: IMExporter::Message
- Defined in:
- lib/im_exporter/message.rb
Overview
A module to handle messages from the iMessage sqlite database
Class Method Summary collapse
-
.is_an_attachment?(message) ⇒ Boolean
checks whether the iMessage is actually an attachment (image).
-
.is_from_me?(message) ⇒ Boolean
checks whether an iMessage is from yourself.
-
.read(id) ⇒ Object
gets metadata about each iMessage.
-
.write(user, message, file_name, file_type) ⇒ Object
writes the iMessage to a PDF or TXT document.
-
.write_logic(message_row, contact_name, file_type) ⇒ Object
the logic behind how things get written to the document.
Class Method Details
.is_an_attachment?(message) ⇒ Boolean
checks whether the iMessage is actually an attachment (image)
42 43 44 |
# File 'lib/im_exporter/message.rb', line 42 def self.() if .eql? 1 then true else false end end |
.is_from_me?(message) ⇒ Boolean
checks whether an iMessage is from yourself
37 38 39 |
# File 'lib/im_exporter/message.rb', line 37 def self.is_from_me?() if .eql? 1 then true else false end end |
.read(id) ⇒ Object
gets metadata about each iMessage
17 18 19 20 21 |
# File 'lib/im_exporter/message.rb', line 17 def self.read(id) select_rows = 'is_from_me, text, cache_has_attachments, rowid, cache_roomnames' query = "select #{select_rows} from message where handle_id= ?" $chat_db.execute(query, id) end |
.write(user, message, file_name, file_type) ⇒ Object
writes the iMessage to a PDF or TXT document
6 7 8 9 10 11 12 13 14 |
# File 'lib/im_exporter/message.rb', line 6 def self.write(user, , file_name, file_type) if file_type.eql? 'PDF' $pdf.font('/Library/Fonts/Times New Roman.ttf') do $pdf.text "#{user}: #{}" end else File.open("#{file_name}.txt", 'a') { |file| file.write("#{user}: #{}\n") } end end |
.write_logic(message_row, contact_name, file_type) ⇒ Object
the logic behind how things get written to the document
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/im_exporter/message.rb', line 24 def self.write_logic(, contact_name, file_type) if self.([2]) IMExporter::Attachment.write([3]) if file_type.eql? 'PDF' else if self.is_from_me?([0]) self.write('me', [1], contact_name, file_type) else self.write(contact_name, [1], contact_name, file_type) end end if [4].nil? end |