class Mail::ContentIdField - mail-2.5.4 Documentation

# class Mail::ContentIdField

### 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/content_id_field.rb, line 10
    def initialize(value = nil, charset = 'utf-8')
      self.charset = charset
      @uniq = 1
      if value.blank?
        value = generate_content_id
      else
        value = strip_field(FIELD_NAME, value)
      end
      super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, value), charset)
      self.parse
      self
    end

### Public Instance Methods

content_id() click to toggle source

    # File lib/mail/fields/content_id_field.rb, line 37
    def content_id
      element.message_id
    end

decoded() click to toggle source

    # File lib/mail/fields/content_id_field.rb, line 50
    def decoded
      "#{to_s}"
    end

element() click to toggle source

    # File lib/mail/fields/content_id_field.rb, line 29
    def element
      @element ||= Mail::MessageIdsElement.new(value)
    end

encoded() click to toggle source

TODO: Fix this up

    # File lib/mail/fields/content_id_field.rb, line 46
    def encoded
      "#{CAPITALIZED_FIELD}: #{to_s}\r\n"
    end

name() click to toggle source

    # File lib/mail/fields/content_id_field.rb, line 33
    def name
      'Content-ID'
    end

parse(val = value) click to toggle source

    # File lib/mail/fields/content_id_field.rb, line 23
    def parse(val = value)
      unless val.blank?
        @element = Mail::MessageIdsElement.new(val)
      end
    end

to_s() click to toggle source

    # File lib/mail/fields/content_id_field.rb, line 41
    def to_s
      "<#{content_id}>"
    end

### Private Instance Methods

generate_content_id() click to toggle source

    # File lib/mail/fields/content_id_field.rb, line 56
    def generate_content_id
      "<#{Mail.random_tag}@#{::Socket.gethostname}.mail>"
    end