Class: ApiParser
- Inherits:
-
Object
- Object
- ApiParser
- Defined in:
- lib/email_api/api/api_parser.rb
Overview
Parser for Email API
Class Method Summary collapse
-
.email_delim ⇒ Object
Accessor for the supported email delimiter.
-
.parse_email(*params) ⇒ EmailObject
Parses parameter inputs into an EmailObject using the supported notation.
Class Method Details
.email_delim ⇒ Object
Accessor for the supported email delimiter
10 11 12 |
# File 'lib/email_api/api/api_parser.rb', line 10 def self.email_delim @email_delim end |
.parse_email(*params) ⇒ EmailObject
Parses parameter inputs into an EmailObject using the supported notation
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/email_api/api/api_parser.rb', line 65 def self.parse_email(*params) email_object = EmailObject.new return email_object if params.nil? || !params.is_a?(Array) || params.empty? to = cc = bcc = subject = content = nil from = params[0] to = params[1] if params.count > 1 cc = params[2] if params.count > 2 bcc = params[3] if params.count > 3 subj_raw = params[4] if params.count > 4 cont_raw = params[5] if params.count > 5 subject = nil if !subj_raw.nil? && (subj_raw.is_a?(String) || subj_raw.is_a?(Numeric)) subject = subj_raw end content = nil if !cont_raw.nil? && (cont_raw.is_a?(String) || cont_raw.is_a?(Numeric)) content = cont_raw end # Parse and assign Message Attributes email_object.from = parse_email_text(from) email_object.to = parse_email_text_arr(to) email_object.cc = parse_email_text_arr(cc) email_object.bcc = parse_email_text_arr(bcc) email_object.subject = (subject.nil? || subject.empty? ? nil : subject) email_object.content = (content.nil? || content.empty? ? nil : content) email_object end |