Class: SmsBackupRenderer::Message
- Inherits:
-
Object
- Object
- SmsBackupRenderer::Message
- Defined in:
- lib/sms_backup_renderer/models.rb
Overview
Represents an SMS or MMS message.
Instance Attribute Summary collapse
-
#date_time ⇒ Object
readonly
Returns a Time instance indicating when the message was sent or received.
-
#outgoing ⇒ Object
readonly
Returns true if the message was sent to address, false if received from address.
-
#participants ⇒ Object
readonly
Returns an Array of Participant instances representing the senders and recipients of the message.
-
#parts ⇒ Object
readonly
Returns an Array of MessagePart instances representing the contents of the message.
-
#subject ⇒ Object
readonly
Returns the String subject/title of the message, likely nil.
Instance Method Summary collapse
-
#initialize(args) ⇒ Message
constructor
A new instance of Message.
-
#sender ⇒ Object
Returns the Participant instance for the message sender, or nil.
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_time ⇒ Object (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 |
#outgoing ⇒ Object (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 |
#participants ⇒ Object (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 |
#parts ⇒ Object (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 |
#subject ⇒ Object (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
#sender ⇒ Object
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 |