Class: DVDConverter::Track

Inherits:
Object
  • Object
show all
Defined in:
lib/dvd_converter/track.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, movie) ⇒ Track

Returns a new instance of Track.



11
12
13
14
15
16
# File 'lib/dvd_converter/track.rb', line 11

def initialize(id, movie)
  self.track_id = id
   self.movie = movie
  self.audio = {}
  self.subtitles = {}
end

Instance Attribute Details

#audioObject

Returns the value of attribute audio.



5
6
7
# File 'lib/dvd_converter/track.rb', line 5

def audio
  @audio
end

#durationObject

Returns the value of attribute duration.



6
7
8
# File 'lib/dvd_converter/track.rb', line 6

def duration
  @duration
end

#movieObject

Returns the value of attribute movie.



8
9
10
# File 'lib/dvd_converter/track.rb', line 8

def movie
  @movie
end

#subtitlesObject

Returns the value of attribute subtitles.



9
10
11
# File 'lib/dvd_converter/track.rb', line 9

def subtitles
  @subtitles
end

#track_idObject

Returns the value of attribute track_id.



7
8
9
# File 'lib/dvd_converter/track.rb', line 7

def track_id
  @track_id
end

Instance Method Details

#convert(options = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/dvd_converter/track.rb', line 18

def convert(options = {})
  as = options[:audio].map { |a| self.audio[a] }
  ss = options[:subtitles].map { |s| self.subtitles[s] }

  converter = Converter.new self, as, ss, options
  converter.process
end

#convert_everything(options = {}) ⇒ Object



26
27
28
29
30
# File 'lib/dvd_converter/track.rb', line 26

def convert_everything(options = {})
  options[:audio] = self.audio.keys.sort
  options[:subtitles] = self.subtitles.keys.sort
  convert options
end


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dvd_converter/track.rb', line 32

def print_description
  print "Track: #{self.track_id}"
  print " Duration: #{self.duration}" if self.duration
  print "\n"
	
  self.audio.keys.sort.each do |key|
    a = self.audio[key]
    a.print_description
  end
	
  self.subtitles.keys.sort.each do |key|
    s = self.subtitles[key]
    s.print_description
  end
	
  puts ''
end