class SmsBackupRenderer::Participant

Represents a single sender or recipient of an SMS or MMS message.

Attributes

address[R]

Returns the String address of the participant, such as ‘1 (234) 567-890’.

name[R]

Returns the String contact name for the participant, or nil if unknown.

owner[R]

Returns true if this participant is the owner of the archive, otherwise false.

sender[R]

Returns true if this participant is a sender of the message, false if they are a recipient.

Public Class Methods

new(args) click to toggle source
# File lib/sms_backup_renderer/models.rb, line 16
def initialize(args)
  @address = args[:address]
  @name = args[:name]
  @owner = args[:owner]
  @sender = args[:sender]
end
normalize_address(address) click to toggle source

Normalizes a given address, for example ‘1 (234) 567-890’ to ‘1234567890’.

TODO: This is currently done in a very hacky, incomplete, embarrassingly-US-centric way.

address - String address to normalize

Returns the String normalized address.

# File lib/sms_backup_renderer/models.rb, line 34
def self.normalize_address(address)
  address.gsub(/[\s\(\)\+\-]/, '')
      .gsub(/\A1(\d{10})\z/, '\\1')
end

Public Instance Methods

normalized_address() click to toggle source
# File lib/sms_backup_renderer/models.rb, line 23
def normalized_address
  @normalized_address ||= Participant.normalize_address(address)
end