Class: Musical::DVD::Chapter

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/musical/dvd/chapter.rb

Constant Summary collapse

DEFAULT_CHAPTER_NUMBER =
1
DEFAULT_CHAPTER_NAME =
'default chapter name'
DEFAULT_TITLE_NUMBER =
1

Constants included from Util

Util::REQUIRED_APPS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#check_env, #execute_command, #installed?

Constructor Details

#initialize(vob_path, options = {}) ⇒ Chapter

Returns a new instance of Chapter.



12
13
14
15
16
17
18
19
# File 'lib/musical/dvd/chapter.rb', line 12

def initialize(vob_path, options = {})
  raise ArgumentError.new 'VOB path is not given' if vob_path.nil?

  @vob_path = vob_path
  @name = options[:name] || DEFAULT_CHAPTER_NAME
  @chapter_number = options[:chapter_number] || DEFAULT_CHAPTER_NUMBER
  @title_number = options[:title_number] || DEFAULT_TITLE_NUMBER
end

Instance Attribute Details

#chapter_numberObject

Returns the value of attribute chapter_number.



6
7
8
# File 'lib/musical/dvd/chapter.rb', line 6

def chapter_number
  @chapter_number
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/musical/dvd/chapter.rb', line 6

def name
  @name
end

#vob_pathObject

Returns the value of attribute vob_path.



6
7
8
# File 'lib/musical/dvd/chapter.rb', line 6

def vob_path
  @vob_path
end

Instance Method Details

#to_wav(wav_path = "#{Musical.configuration.output}/chapter_#{@title_number}_#{@chapter_number}.wav") ⇒ Object



21
22
23
24
25
26
27
# File 'lib/musical/dvd/chapter.rb', line 21

def to_wav(wav_path = "#{Musical.configuration.output}/chapter_#{@title_number}_#{@chapter_number}.wav")
  return @wav if @wav

  command = "ffmpeg -i #{@vob_path} -ac 2 #{wav_path}"
  execute_command(command, true)
  DVD::Wav.new(wav_path)
end