Class: Bookit::Emitter::Mobi
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
Instance Method Details
#filepath ⇒ Object
36
37
38
|
# File 'lib/bookit/emitter/mobi.rb', line 36
def filepath
File.join(File.dirname(@path), 'out.mobi')
end
|
#generate ⇒ Object
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
|
# File 'lib/bookit/emitter/mobi.rb', line 6
def generate
tfile = Tempfile.new(["temp", ".html"])
tfile.write %{
<!DOCTYPE html>
<html>
<metadata>
<dc:Title>#{@article.title}</dc:Title>
</metadata>
<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
@path = tfile.path
`kindlegen -c2 #{@path} -o out.mobi`
self
end
|
#render ⇒ Object
40
41
42
|
# File 'lib/bookit/emitter/mobi.rb', line 40
def render
IO.binread(filepath)
end
|
#save(filename) ⇒ Object
44
45
46
47
48
|
# File 'lib/bookit/emitter/mobi.rb', line 44
def save(filename)
File.open(filename, 'w') do |f|
f << File.read(filepath)
end
end
|