Class: BomDB::Export::Books

Inherits:
Base
  • Object
show all
Defined in:
lib/bomdb/export/books.rb

Instance Attribute Summary

Attributes inherited from Base

#db, #opts

Instance Method Summary collapse

Methods inherited from Base

#export, #initialize

Constructor Details

This class inherits a constructor from BomDB::Export::Base

Instance Method Details

#export_jsonObject



6
7
8
9
10
11
12
13
14
# File 'lib/bomdb/export/books.rb', line 6

def export_json
  books = []
  select_books.each do |b|
    fields = [ b[:book_name], b[:book_group], b[:book_sort] ]
    fields << @db[:verses].where(:book_id => b[:book_id]).max(:verse_chapter)
    books << JSON::generate(fields, array_nl: ' ')
  end
  Export::Result.new(success: true, body: "[\n  " + books.join(",\n  ") + "\n]\n")
end

#export_textObject



16
17
18
# File 'lib/bomdb/export/books.rb', line 16

def export_text
  Export::Result.new(success: true, body: select_books.map{ |b| b[:book_name] }.join("\n"))
end