Class: BomDB::Export::Base

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

Direct Known Subclasses

Books, Contents, Editions, Verses

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, **opts) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/bomdb/export/base.rb', line 6

def initialize(db, **opts)
  @db = db
  @opts = opts
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



4
5
6
# File 'lib/bomdb/export/base.rb', line 4

def db
  @db
end

#optsObject (readonly)

Returns the value of attribute opts.



4
5
6
# File 'lib/bomdb/export/base.rb', line 4

def opts
  @opts
end

Instance Method Details

#export(format: 'json', **options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bomdb/export/base.rb', line 11

def export(format: 'json', **options)
  case format
  when 'json' then export_json
  when 'text' then export_text
  else
    return Import::Result.new(
      success: false,
      error: "Unknown format: #{format}"
    )
  end
end