Class: DigestEmail::DigestParser
Class Method Summary
collapse
valid_index?, validate_index, validate_indices
Class Method Details
.parse(digest) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/digest_email/digest_parser.rb', line 7
def self.parse(digest)
begin
validate_indices(digest, ["header", "items", "footer"])
= (digest["header"])
body = parse_items(digest["items"])
= (digest["footer"])
DigestEmail::Digest.new(, body, )
rescue Exception => e
raise "Failed to parse digest: #{e.message}"
end
end
|
36
37
38
39
|
# File 'lib/digest_email/digest_parser.rb', line 36
def self.()
validate_indices(, ["signature", "sponsors_image"])
DigestEmail::DigestFooter.new
end
|
21
22
23
24
|
# File 'lib/digest_email/digest_parser.rb', line 21
def self.()
validate_index(, "title")
DigestEmail::DigestHeader.new
end
|
.parse_item(item) ⇒ Object
30
31
32
33
34
|
# File 'lib/digest_email/digest_parser.rb', line 30
def self.parse_item(item)
validate_indices(item, ["list_title", "image", "title", "body"])
DigestEmail::DigestItem.new item
end
|
.parse_items(items) ⇒ Object
26
27
28
|
# File 'lib/digest_email/digest_parser.rb', line 26
def self.parse_items(items)
DigestEmail::DigestItems.new items.map{|item| parse_item(item)}
end
|