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.


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

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

Class Method Details

.singular?Boolean

Returns:

  • (Boolean)

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

def self.singular?
  true
end

Instance Method Details

#decodedObject


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

def decoded
  version
end

#elementObject


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

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

#encodedObject


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

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

#majorObject


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

def major
  element.major.to_i
end

#minorObject


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

def minor
  element.minor.to_i
end

#versionObject


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

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