Class: Mail::ContentTransferEncodingField

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

Overview

:nodoc:

Constant Summary collapse

NAME =
'Content-Transfer-Encoding'

Instance Attribute Summary

Attributes inherited from CommonField

#charset, #errors, #name, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CommonField

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

Constructor Details

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

Returns a new instance of ContentTransferEncodingField.



24
25
26
# File 'lib/mail/fields/content_transfer_encoding_field.rb', line 24

def initialize(value = nil, charset = nil)
  super self.class.normalize_content_transfer_encoding(value), charset
end

Class Method Details

.normalize_content_transfer_encoding(value) ⇒ Object



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

def self.normalize_content_transfer_encoding(value)
  case value
  when /7-?bits?/i
    '7bit'
  when /8-?bits?/i
    '8bit'
  else
    value
  end
end

.singular?Boolean

Returns:

  • (Boolean)


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

def self.singular?
  true
end

Instance Method Details

#elementObject



28
29
30
# File 'lib/mail/fields/content_transfer_encoding_field.rb', line 28

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

#encodingObject



32
33
34
# File 'lib/mail/fields/content_transfer_encoding_field.rb', line 32

def encoding
  element.encoding
end