# class Mail::ReceivedField

### Constants

CAPITALIZED_FIELD
FIELD_NAME

### Public Class Methods

new(value = nil, charset = 'utf-8') click to toggle source
Calls superclass method

    # File lib/mail/fields/received_field.rb, line 27
    def initialize(value = nil, charset = 'utf-8')
      self.charset = charset
      super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, value), charset)
      self.parse
      self

    end

### Public Instance Methods

date_time() click to toggle source

    # File lib/mail/fields/received_field.rb, line 45
    def date_time
      @datetime ||= ::DateTime.parse("#{element.date_time}")
    end

decoded() click to toggle source

    # File lib/mail/fields/received_field.rb, line 65
    def decoded
      if Utilities.blank?(value)
        ""
      else
        "#{info}; #{formatted_date}"
      end
    end

element() click to toggle source

    # File lib/mail/fields/received_field.rb, line 41
    def element
      @element ||= Mail::ReceivedElement.new(value)
    end

encoded() click to toggle source

    # File lib/mail/fields/received_field.rb, line 57
    def encoded
      if Utilities.blank?(value)
        "#{CAPITALIZED_FIELD}: \r\n"
      else
        "#{CAPITALIZED_FIELD}: #{info}; #{formatted_date}\r\n"
      end
    end

formatted_date() click to toggle source

    # File lib/mail/fields/received_field.rb, line 53
    def formatted_date
      date_time.strftime("%a, %d %b %Y %H:%M:%S ") + date_time.zone.delete(':')
    end

info() click to toggle source

    # File lib/mail/fields/received_field.rb, line 49
    def info
      element.info
    end

parse(val = value) click to toggle source

    # File lib/mail/fields/received_field.rb, line 35
    def parse(val = value)
      unless Utilities.blank?(val)
        @element = Mail::ReceivedElement.new(val)
      end
    end