class MailXSMTPAPI::Field

Constants

CAPITALIZED_FIELD
FIELD_NAME

Attributes

data[R]

Public Class Methods

new(value = nil, charset = 'utf-8') click to toggle source
# File lib/mail_x_smtpapi/field.rb, line 21
def initialize(value = nil, charset = 'utf-8')
  self.charset = charset
  self.name = CAPITALIZED_FIELD
  @data = value || {}
end

Public Instance Methods

decoded() click to toggle source

to take advantage of folding, decoded must return a string of JSON with extra spaces inserted for line wrapping.

# File lib/mail_x_smtpapi/field.rb, line 41
def decoded
  value.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
end
empty?() click to toggle source
# File lib/mail_x_smtpapi/field.rb, line 45
def empty?
  data.values.all?{|v| !v || v.empty? }
end
encoded() click to toggle source
# File lib/mail_x_smtpapi/field.rb, line 31
def encoded
  if empty?
    ''
  else
    "#{wrapped_value}\r\n"
  end
end
value() click to toggle source
# File lib/mail_x_smtpapi/field.rb, line 27
def value
  JSON.generate(data)
end