Class: NcodeSyosetu::Builder::Mobi

Inherits:
Object
  • Object
show all
Defined in:
lib/ncode_syosetu/builder/mobi.rb

Class Method Summary collapse

Class Method Details

.write(novel, mobi_path) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ncode_syosetu/builder/mobi.rb', line 7

def self.write(novel, mobi_path)
  mobi_pathname = Pathname.new(mobi_path)
  mobi_basename = mobi_pathname.basename.to_s
  Dir.mktmpdir do |tmpdir|
    epub_path = File.join(tmpdir, "#{mobi_basename}.epub")
    NcodeSyosetu::Builder::Epub3.write(novel, epub_path)
    STDERR.puts Kindlegen.run(epub_path,
                  "-verbose",
                  "-locale", "ja",
                  "-o", mobi_basename)
    File.rename(File.join(tmpdir, mobi_basename), mobi_path)
  end
end