class AudioBookCreator::Binder

Attributes

book_def[RW]
speaker_def[RW]

Public Class Methods

new(book_def, speaker_def) click to toggle source

these are more for documentation than actual variables

# File lib/audio_book_creator/binder.rb, line 8
def initialize(book_def, speaker_def)
  @book_def = book_def
  @speaker_def = speaker_def
end

Public Instance Methods

create(chapters) click to toggle source
# File lib/audio_book_creator/binder.rb, line 13
def create(chapters)
  raise "No Chapters" if chapters.nil? || chapters.empty?

  AudioBookCreator.optionally_run(book_def.filename, force) do
    ["abbinder", params: params(chapters)]
  end
end

Private Instance Methods

cfilename(chapter) click to toggle source
# File lib/audio_book_creator/binder.rb, line 58
def cfilename(chapter)
  chapter.filename
end
chapter_params(chapters) click to toggle source
# File lib/audio_book_creator/binder.rb, line 50
def chapter_params(chapters)
  chapters.map { |ch| [ctitle(ch), cfilename(ch)] }
end
ctitle(chapter) click to toggle source
# File lib/audio_book_creator/binder.rb, line 54
def ctitle(chapter)
  "@#{chapter.title}@"
end
force() click to toggle source
# File lib/audio_book_creator/binder.rb, line 23
def force
  speaker_def.regen_audio
end
itunes() click to toggle source
# File lib/audio_book_creator/binder.rb, line 27
def itunes
  book_def.itunes
end
params(chapters) click to toggle source
# File lib/audio_book_creator/binder.rb, line 31
def params(chapters)
  ret = {
    "-A" => nil,
    "-a" => book_def.author,
    "-t" => book_def.title,
    "-b" => speaker_def.bit_rate,
    "-c" => speaker_def.channels,
    "-r" => speaker_def.sample_rate,
    "-g" => "Audiobook",
    "-l" => speaker_def.max_hours,
    "-o" => book_def.filename,
    # "-v" => verbose,
    # "-C" => "file.png" cover image
    nil  => chapter_params(chapters),
  }
  ret.delete("-A") unless itunes # add audiobook to iTunes
  ret
end