Sha256: 5d982b3995462bf0a72eaa223d595ea29759b348ad7c5c9bdc97d1c5fa12628c

Contents?: true

Size: 913 Bytes

Versions: 4

Compression:

Stored size: 913 Bytes

Contents

# encoding: utf-8
# 
# 
# 
module Mail
  class MimeVersionField < StructuredField
    
    FIELD_NAME = 'mime-version'
    CAPITALIZED_FIELD = 'Mime-Version'

    def initialize(*args)
      if args.last.blank?
        self.name = CAPITALIZED_FIELD
        self.value = '1.0'
      else
        super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, args.last))
      end
      self.parse
      self

    end
    
    def parse(val = value)
      unless val.blank?
        @element = Mail::MimeVersionElement.new(val)
      end
    end
    
    def element
      @element ||= Mail::MimeVersionElement.new(value)
    end
    
    def version
      "#{element.major}.#{element.minor}"
    end

    def major
      element.major.to_i
    end

    def minor
      element.minor.to_i
    end
    
    def encoded
      "#{CAPITALIZED_FIELD}: #{version}\r\n"
    end
    
    def decoded
      version
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mail-2.1.5.3 lib/mail/fields/mime_version_field.rb
mail-2.1.5.2 lib/mail/fields/mime_version_field.rb
mail-2.1.5.1 lib/mail/fields/mime_version_field.rb
mail-2.1.5 lib/mail/fields/mime_version_field.rb