Class: Mail::CommonField

Inherits:
Object
  • Object
show all
Defined in:
lib/mail/fields/common_field.rb

Overview

:nodoc:

Direct Known Subclasses

StructuredField, UnstructuredField

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, value = nil, charset = nil) ⇒ CommonField

Returns a new instance of CommonField.



20
21
22
23
24
25
26
# File 'lib/mail/fields/common_field.rb', line 20

def initialize(name = nil, value = nil, charset = nil)
  @errors = []

  self.name = name
  self.value = value
  self.charset = charset || 'utf-8'
end

Instance Attribute Details

#charsetObject

Returns the value of attribute charset.



17
18
19
# File 'lib/mail/fields/common_field.rb', line 17

def charset
  @charset
end

#errorsObject (readonly)

Returns the value of attribute errors.



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

def errors
  @errors
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#valueObject

Returns the value of attribute value.



16
17
18
# File 'lib/mail/fields/common_field.rb', line 16

def value
  @value
end

Class Method Details

.parse(*args) ⇒ Object



11
12
13
# File 'lib/mail/fields/common_field.rb', line 11

def self.parse(*args)
  new(*args).tap(&:parse)
end

.singular?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/mail/fields/common_field.rb', line 7

def self.singular?
  false
end

Instance Method Details

#decodedObject



54
55
56
# File 'lib/mail/fields/common_field.rb', line 54

def decoded
  do_decode
end

#defaultObject



50
51
52
# File 'lib/mail/fields/common_field.rb', line 50

def default
  decoded
end

#elementObject



42
43
44
# File 'lib/mail/fields/common_field.rb', line 42

def element
  nil
end

#encodedObject



58
59
60
# File 'lib/mail/fields/common_field.rb', line 58

def encoded
  do_encode
end

#parseObject



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

def parse
  tap(&:element)
end

#responsible_for?(field_name) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/mail/fields/common_field.rb', line 62

def responsible_for?(field_name)
  name.to_s.casecmp(field_name.to_s) == 0
end

#singular?Boolean

Returns:

  • (Boolean)


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

def singular?
  self.class.singular?
end

#to_sObject



46
47
48
# File 'lib/mail/fields/common_field.rb', line 46

def to_s
  decoded.to_s
end