Class: Ehbrs::Tools::Runner::Videos::Languages::Track

Inherits:
Labelized
  • Object
show all
Defined in:
lib/ehbrs/tools/runner/videos/languages/track.rb

Constant Summary collapse

BLANK_LANGUAGE =
'BLANK'

Instance Attribute Summary collapse

Attributes inherited from Labelized

#runner

Instance Method Summary collapse

Methods inherited from Labelized

#to_label

Constructor Details

#initialize(runner, object, file) ⇒ Track

Returns a new instance of Track.



16
17
18
19
# File 'lib/ehbrs/tools/runner/videos/languages/track.rb', line 16

def initialize(runner, object, file)
  super(runner, object)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



14
15
16
# File 'lib/ehbrs/tools/runner/videos/languages/track.rb', line 14

def file
  @file
end

Instance Method Details

#delete_ffmpeg_argsObject



21
22
23
24
25
# File 'lib/ehbrs/tools/runner/videos/languages/track.rb', line 21

def delete_ffmpeg_args
  return [] if included?

  ['-map', "-0:#{index}"]
end

#extract_ffmpeg_argsObject



27
28
29
30
31
# File 'lib/ehbrs/tools/runner/videos/languages/track.rb', line 27

def extract_ffmpeg_args
  return [] unless included?

  ['-map', "0:#{index}", extract_target]
end

#extract_targetObject



41
42
43
# File 'lib/ehbrs/tools/runner/videos/languages/track.rb', line 41

def extract_target
  file.basename_sub('.*') { |b| "#{b}.#{language}_#{index}.srt" }
end

#included?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/ehbrs/tools/runner/videos/languages/track.rb', line 33

def included?
  runner.keep_languages.include?(language)
end

#languageObject



37
38
39
# File 'lib/ehbrs/tools/runner/videos/languages/track.rb', line 37

def language
  language_with_title.presence || BLANK_LANGUAGE
end