Class: Mail::ReceivedField

Inherits:
StructuredField show all
Defined in:
lib/mail/fields/received_field.rb

Constant Summary collapse

FIELD_NAME =
'received'
CAPITALIZED_FIELD =
'Received'

Instance Method Summary collapse

Methods inherited from StructuredField

#default

Methods included from Utilities

included

Methods included from CommonField

included

Constructor Details

#initialize(*args) ⇒ ReceivedField

Returns a new instance of ReceivedField.



28
29
30
31
32
33
# File 'lib/mail/fields/received_field.rb', line 28

def initialize(*args)
  super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, args.last))
  self.parse
  self

end

Instance Method Details

#date_timeObject



45
46
47
# File 'lib/mail/fields/received_field.rb', line 45

def date_time
  ::DateTime.parse("#{element.date_time}")
end

#decodedObject



57
58
59
# File 'lib/mail/fields/received_field.rb', line 57

def decoded
  value
end

#elementObject



41
42
43
# File 'lib/mail/fields/received_field.rb', line 41

def element
  @element ||= Mail::ReceivedElement.new(value)
end

#encodedObject



53
54
55
# File 'lib/mail/fields/received_field.rb', line 53

def encoded
  "#{CAPITALIZED_FIELD}: #{value}"
end

#infoObject



49
50
51
# File 'lib/mail/fields/received_field.rb', line 49

def info
  element.info
end

#parse(val = value) ⇒ Object



35
36
37
38
39
# File 'lib/mail/fields/received_field.rb', line 35

def parse(val = value)
  unless val.blank?
    @element = Mail::ReceivedElement.new(val)
  end
end