Class: Mail::DateField

Inherits:
StructuredField show all
Includes:
CommonDate
Defined in:
lib/mail/fields/date_field.rb

Constant Summary collapse

FIELD_NAME =
'date'
CAPITALIZED_FIELD =
"Date"

Instance Method Summary collapse

Methods included from CommonDate

included

Methods inherited from StructuredField

#default

Methods included from Utilities

included

Methods included from CommonField

included

Constructor Details

#initialize(*args) ⇒ DateField

Returns a new instance of DateField.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mail/fields/date_field.rb', line 32

def initialize(*args)
  if args.last.blank?
    self.name = CAPITALIZED_FIELD
    self.value = Time.now.strftime('%a, %d %b %Y %H:%M:%S %z')
    self
  else
    value = strip_field(FIELD_NAME, args.last)
    value = ::DateTime.parse(value.to_s).strftime('%a, %d %b %Y %H:%M:%S %z')
    super(CAPITALIZED_FIELD, value)
  end
end

Instance Method Details

#decodedObject



48
49
50
# File 'lib/mail/fields/date_field.rb', line 48

def decoded
  do_decode
end

#encodedObject



44
45
46
# File 'lib/mail/fields/date_field.rb', line 44

def encoded
  do_encode(CAPITALIZED_FIELD)
end