Class: EbookLibrary::EbookFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/ebook_library/ebook_factory.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format, metadata) ⇒ EbookFactory

Returns a new instance of EbookFactory.



5
6
7
8
# File 'lib/ebook_library/ebook_factory.rb', line 5

def initialize(format, )
  raise UnsupportedFormatError unless %w(epub mobi pdf).include? format
  @adapter = for_type(format).new()
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



4
5
6
# File 'lib/ebook_library/ebook_factory.rb', line 4

def adapter
  @adapter
end

Class Method Details

.supported_typesObject



10
11
12
# File 'lib/ebook_library/ebook_factory.rb', line 10

def self.supported_types
  %w(epub mobi pdf)
end

Instance Method Details

#authorObject



18
19
20
# File 'lib/ebook_library/ebook_factory.rb', line 18

def author
  Maybe(adapter).author._("").encode('UTF-8', encode_options)
end

#titleObject



14
15
16
# File 'lib/ebook_library/ebook_factory.rb', line 14

def title
  Maybe(adapter).title._("untitled").encode('UTF-8', encode_options)
end