Class: SmsBackupRenderer::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_backup_renderer/models.rb

Overview

Represents an SMS or MMS message.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Message

Returns a new instance of Message.



60
61
62
63
64
65
66
67
# File 'lib/sms_backup_renderer/models.rb', line 60

def initialize(args)
  @contact_name = args[:contact_name]
  @date_time = args[:date_time]
  @outgoing = args[:outgoing]
  @participants = args[:participants]
  @parts = args[:parts] || []
  @subject = args[:subject]
end

Instance Attribute Details

#date_timeObject (readonly)

Returns a Time instance indicating when the message was sent or received.



43
44
45
# File 'lib/sms_backup_renderer/models.rb', line 43

def date_time
  @date_time
end

#outgoingObject (readonly)

Returns true if the message was sent to address, false if received from address.



46
47
48
# File 'lib/sms_backup_renderer/models.rb', line 46

def outgoing
  @outgoing
end

#participantsObject (readonly)

Returns an Array of Participant instances representing the senders and recipients of the message.

For MMS messages there may be multiple recipients. For SMS messages, the originator of the archive
is never represented, so there will only be a sender (for incoming messages) or a recipient
(for outgoing messages).


52
53
54
# File 'lib/sms_backup_renderer/models.rb', line 52

def participants
  @participants
end

#partsObject (readonly)

Returns an Array of MessagePart instances representing the contents of the message.



55
56
57
# File 'lib/sms_backup_renderer/models.rb', line 55

def parts
  @parts
end

#subjectObject (readonly)

Returns the String subject/title of the message, likely nil.



58
59
60
# File 'lib/sms_backup_renderer/models.rb', line 58

def subject
  @subject
end

Instance Method Details

#senderObject

Returns the Participant instance for the message sender, or nil.



70
71
72
# File 'lib/sms_backup_renderer/models.rb', line 70

def sender
  @sender ||= participants.detect(&:sender)
end