Class: Smtpapi::Header
- Inherits:
-
Object
- Object
- Smtpapi::Header
- Defined in:
- lib/smtpapi.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#send_at ⇒ Object
readonly
Returns the value of attribute send_at.
-
#send_each_at ⇒ Object
readonly
Returns the value of attribute send_each_at.
-
#sub ⇒ Object
readonly
Returns the value of attribute sub.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#unique_args ⇒ Object
readonly
Returns the value of attribute unique_args.
Instance Method Summary collapse
- #add_category(category) ⇒ Object
- #add_filter(filter_name, parameter_name, parameter_value) ⇒ Object
- #add_section(key, value) ⇒ Object
- #add_substitution(sub, values) ⇒ Object
- #add_to(address, name = nil) ⇒ Object
- #add_unique_arg(key, value) ⇒ Object
- #escape_unicode(str) ⇒ Object
-
#initialize ⇒ Header
constructor
A new instance of Header.
- #json_string ⇒ Object (also: #to_json)
- #set_categories(categories) ⇒ Object
- #set_filters(filters) ⇒ Object
- #set_sections(key_value_pairs) ⇒ Object
- #set_send_at(send_at) ⇒ Object
- #set_send_each_at(send_each_at) ⇒ Object
- #set_substitutions(key_value_pairs) ⇒ Object
- #set_tos(addresses) ⇒ Object
- #set_unique_args(key_value_pairs) ⇒ Object
Constructor Details
#initialize ⇒ Header
Returns a new instance of Header.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/smtpapi.rb', line 11 def initialize @to = [] @sub = {} @section = {} @category = [] @unique_args = {} @filters = {} @send_at = nil @send_each_at = [] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
9 10 11 |
# File 'lib/smtpapi.rb', line 9 def category @category end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
9 10 11 |
# File 'lib/smtpapi.rb', line 9 def filters @filters end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
9 10 11 |
# File 'lib/smtpapi.rb', line 9 def section @section end |
#send_at ⇒ Object (readonly)
Returns the value of attribute send_at.
9 10 11 |
# File 'lib/smtpapi.rb', line 9 def send_at @send_at end |
#send_each_at ⇒ Object (readonly)
Returns the value of attribute send_each_at.
9 10 11 |
# File 'lib/smtpapi.rb', line 9 def send_each_at @send_each_at end |
#sub ⇒ Object (readonly)
Returns the value of attribute sub.
9 10 11 |
# File 'lib/smtpapi.rb', line 9 def sub @sub end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
9 10 11 |
# File 'lib/smtpapi.rb', line 9 def to @to end |
#unique_args ⇒ Object (readonly)
Returns the value of attribute unique_args.
9 10 11 |
# File 'lib/smtpapi.rb', line 9 def unique_args @unique_args end |
Instance Method Details
#add_category(category) ⇒ Object
64 65 66 67 |
# File 'lib/smtpapi.rb', line 64 def add_category(category) @category.push(category) self end |
#add_filter(filter_name, parameter_name, parameter_value) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/smtpapi.rb', line 74 def add_filter(filter_name, parameter_name, parameter_value) @filters[filter_name] = {} if @filters[filter_name] == nil @filters[filter_name]['settings'] = {} if @filters[filter_name]['settings'] == nil @filters[filter_name]['settings'][parameter_name] = parameter_value self end |
#add_section(key, value) ⇒ Object
44 45 46 47 |
# File 'lib/smtpapi.rb', line 44 def add_section(key, value) @section[key] = value self end |
#add_substitution(sub, values) ⇒ Object
34 35 36 37 |
# File 'lib/smtpapi.rb', line 34 def add_substitution(sub, values) @sub[sub] = values self end |
#add_to(address, name = nil) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/smtpapi.rb', line 22 def add_to(address, name=nil) value = address value = "#{name} <#{address}>" if name != nil @to.push(value) self end |
#add_unique_arg(key, value) ⇒ Object
54 55 56 57 |
# File 'lib/smtpapi.rb', line 54 def add_unique_arg(key, value) @unique_args[key] = value self end |
#escape_unicode(str) ⇒ Object
117 118 119 |
# File 'lib/smtpapi.rb', line 117 def escape_unicode(str) str.unpack('U*').map{|i| i > 127 ? "\\u#{i.to_s(16)}" : i.chr("UTF-8")}.join end |
#json_string ⇒ Object Also known as: to_json
112 113 114 |
# File 'lib/smtpapi.rb', line 112 def json_string escape_unicode(self.to_array.to_json) end |
#set_categories(categories) ⇒ Object
69 70 71 72 |
# File 'lib/smtpapi.rb', line 69 def set_categories(categories) @category = categories self end |
#set_filters(filters) ⇒ Object
81 82 83 84 |
# File 'lib/smtpapi.rb', line 81 def set_filters(filters) @filters = filters self end |
#set_sections(key_value_pairs) ⇒ Object
49 50 51 52 |
# File 'lib/smtpapi.rb', line 49 def set_sections(key_value_pairs) @section = key_value_pairs self end |
#set_send_at(send_at) ⇒ Object
86 87 88 |
# File 'lib/smtpapi.rb', line 86 def set_send_at(send_at) @send_at = send_at end |
#set_send_each_at(send_each_at) ⇒ Object
90 91 92 |
# File 'lib/smtpapi.rb', line 90 def set_send_each_at(send_each_at) @send_each_at = send_each_at end |
#set_substitutions(key_value_pairs) ⇒ Object
39 40 41 42 |
# File 'lib/smtpapi.rb', line 39 def set_substitutions(key_value_pairs) @sub = key_value_pairs self end |
#set_tos(addresses) ⇒ Object
29 30 31 32 |
# File 'lib/smtpapi.rb', line 29 def set_tos(addresses) @to = addresses self end |
#set_unique_args(key_value_pairs) ⇒ Object
59 60 61 62 |
# File 'lib/smtpapi.rb', line 59 def set_unique_args(key_value_pairs) @unique_args = key_value_pairs self end |