Class: BomDB::Export::Contents
- Inherits:
-
Base
- Object
- Base
- BomDB::Export::Contents
show all
- Defined in:
- lib/bomdb/export/contents.rb
Instance Attribute Summary
Attributes inherited from Base
#db, #opts
Instance Method Summary
collapse
Methods inherited from Base
#export, #initialize
Instance Method Details
#export_json ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/bomdb/export/contents.rb', line 7
def export_json
editions_by_id = selected_editions()
contents = {}
content_query(editions_by_id.keys).each do |r|
edition = editions_by_id[ r[:edition_id] ]
book = (contents[ r[:book_name] ] ||= {})
chapter = (book[ r[:verse_chapter] ] ||= {})
verse = (chapter[ full_verse_ref(r) ] ||= {})
verse[ edition[:edition_year] ] = r[:content_body]
end
frame = {
editions: editions_legend(editions_by_id),
contents: contents
}
Export::Result.new(success: true, body: JSON.pretty_generate(frame))
end
|
#export_text ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/bomdb/export/contents.rb', line 27
def export_text
editions_by_id = selected_editions()
output = ""
editions_by_id.each_pair do |id, edition|
title = edition[:edition_name]
output << title + "\n"
output << ('=' * title.size) + "\n"
content_query([id]).each do |r|
output << full_verse_ref(r) + "\t" + r[:content_body] + "\n"
end
output << "\n"
end
Export::Result.new(success: true, body: output)
end
|