Class: Bookit::Emitter::Epub

Inherits:
Abstract show all
Defined in:
lib/bookit/emitter/epub.rb

Constant Summary

Constants inherited from Abstract

Abstract::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Abstract

#article, #options

Instance Method Summary collapse

Methods inherited from Abstract

#initialize

Constructor Details

This class inherits a constructor from Bookit::Emitter::Abstract

Instance Method Details

#generateObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bookit/emitter/epub.rb', line 6

def generate
  tfile = Tempfile.new(["temp", ".html"])
  tfile.write %{
    <!DOCTYPE html> 
    <html>
      <body>
        <h1>#{@article.title}</h1>
        <b>#{@article.author}</b>
        <br/>
        <i>
            #{@article.date_published}
            <br/>
            #{@article.url}
        </i>
        <br/>
        #{@article.content.raw_content}
      </body>
    </html>
  }

  tfile.close

  data = @article
  epub = EeePub.make do
    title       data.title
    date        data.date_published
    creator     data.author
    identifier  data.url, scheme: "URL"
    uid         data.url
    
    files       [File.expand_path(tfile.path)]
  end

  epub
end