Class: Mail::MimeVersionField

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

Constant Summary collapse

FIELD_NAME =
'mime-version'
CAPITALIZED_FIELD =
'Mime-Version'

Instance Method Summary collapse

Methods inherited from StructuredField

#default

Methods included from Utilities

included

Methods included from CommonField

included

Constructor Details

#initialize(*args) ⇒ MimeVersionField

Returns a new instance of MimeVersionField.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mail/fields/mime_version_field.rb', line 11

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

Instance Method Details

#decodedObject



49
50
51
# File 'lib/mail/fields/mime_version_field.rb', line 49

def decoded
  value
end

#elementObject



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

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

#encodedObject



45
46
47
# File 'lib/mail/fields/mime_version_field.rb', line 45

def encoded
  "#{CAPITALIZED_FIELD}: #{value}\r\n"
end

#majorObject



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

def major
  element.major.to_i
end

#minorObject



41
42
43
# File 'lib/mail/fields/mime_version_field.rb', line 41

def minor
  element.minor.to_i
end

#parse(val = value) ⇒ Object



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

def parse(val = value)
  unless val.blank?
    @element = Mail::MimeVersionElement.new(val)
  end
end

#versionObject



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

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