Class: EbooksRenamer::EpubParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ebooks_renamer/epub_parser.rb

Class Method Summary collapse

Class Method Details

.parse(filename) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ebooks_renamer/epub_parser.rb', line 4

def parse(filename)
  info = EPUBInfo.get(filename)
  if info.present?
    title     = info.titles.first if info.titles
    author    = info.creators.map(&:name).first if info.creators
    publisher = info.publisher
    if title.present?
      OpenStruct.new title:     title,
                     author:    author,
                     publisher: publisher
    end
  end
end