Class: Mailarchiva::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/mailarchiva/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, field_values) ⇒ Message

Returns a new instance of Message.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mailarchiva/message.rb', line 9

def initialize(client, field_values)
  @client = client
  field_values[:field_values].each do |field|
    key = field[:field]
    value = field[:value]
    case key
      when /date/
        value = DateTime.parse(value) if value
      when /size/
        value = value.to_i if value
      else
        value
    end
    instance_variable_set("@#{key}", value) if respond_to?(key.to_sym)
  end
  @blob_id = field_values[:id][:blob_id]
  @volume_id = field_values[:id][:volume_id]
end

Instance Attribute Details

#archivedateObject

Returns the value of attribute archivedate.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def archivedate
  @archivedate
end

#bccObject

Returns the value of attribute bcc.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def bcc
  @bcc
end

#blob_idObject

Returns the value of attribute blob_id.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def blob_id
  @blob_id
end

#ccObject

Returns the value of attribute cc.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def cc
  @cc
end

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def client
  @client
end

#deliveredtoObject

Returns the value of attribute deliveredto.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def deliveredto
  @deliveredto
end

#fromObject

Returns the value of attribute from.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def from
  @from
end

#mailfromObject

Returns the value of attribute mailfrom.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def mailfrom
  @mailfrom
end

#messageidObject

Returns the value of attribute messageid.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def messageid
  @messageid
end

#rcpttoObject

Returns the value of attribute rcptto.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def rcptto
  @rcptto
end

#receiveddateObject

Returns the value of attribute receiveddate.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def receiveddate
  @receiveddate
end

#sentdateObject

Returns the value of attribute sentdate.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def sentdate
  @sentdate
end

#sizeObject

Returns the value of attribute size.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def size
  @size
end

#subjectObject

Returns the value of attribute subject.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def subject
  @subject
end

#toObject

Returns the value of attribute to.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def to
  @to
end

#volume_idObject

Returns the value of attribute volume_id.



7
8
9
# File 'lib/mailarchiva/message.rb', line 7

def volume_id
  @volume_id
end

Instance Method Details

#mail_messageObject



52
53
54
# File 'lib/mailarchiva/message.rb', line 52

def mail_message
  @mail_message ||= @client.get_mail_message(@blob_id, @volume_id)
end

#raw_fromObject



28
29
30
# File 'lib/mailarchiva/message.rb', line 28

def raw_from
  @from
end

#raw_messageObject



48
49
50
# File 'lib/mailarchiva/message.rb', line 48

def raw_message
  @raw_message ||= @client.get_message(@blob_id, @volume_id)
end

#raw_toObject



36
37
38
# File 'lib/mailarchiva/message.rb', line 36

def raw_to
  @to
end

#undisclosed_recipients?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/mailarchiva/message.rb', line 56

def undisclosed_recipients?
  raw_to.nil? || (raw_to =~ /undisclosed-recipients/i) == 1
end