Class: Mail::MimeVersionField

Inherits:
NamedStructuredField show all
Defined in:
lib/mail/fields/mime_version_field.rb

Overview

:nodoc:

Constant Summary collapse

NAME =
'MIME-Version'

Instance Attribute Summary

Attributes inherited from CommonField

#charset, #errors, #name, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CommonField

#default, #parse, parse, #responsible_for?, #singular?, #to_s

Constructor Details

#initialize(value = nil, charset = nil) ⇒ MimeVersionField

Returns a new instance of MimeVersionField.



13
14
15
16
# File 'lib/mail/fields/mime_version_field.rb', line 13

def initialize(value = nil, charset = nil)
  value = '1.0' if Utilities.blank?(value)
  super value, charset
end

Class Method Details

.singular?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/mail/fields/mime_version_field.rb', line 9

def self.singular?
  true
end

Instance Method Details

#decodedObject



38
39
40
# File 'lib/mail/fields/mime_version_field.rb', line 38

def decoded
  version
end

#elementObject



18
19
20
# File 'lib/mail/fields/mime_version_field.rb', line 18

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

#encodedObject



34
35
36
# File 'lib/mail/fields/mime_version_field.rb', line 34

def encoded
  "#{name}: #{version}\r\n"
end

#majorObject



26
27
28
# File 'lib/mail/fields/mime_version_field.rb', line 26

def major
  element.major.to_i
end

#minorObject



30
31
32
# File 'lib/mail/fields/mime_version_field.rb', line 30

def minor
  element.minor.to_i
end

#versionObject



22
23
24
# File 'lib/mail/fields/mime_version_field.rb', line 22

def version
  "#{element.major}.#{element.minor}"
end