Class: EhbrsRubyUtils::Videos2::ConvertJob
- Inherits:
-
Object
- Object
- EhbrsRubyUtils::Videos2::ConvertJob
- Defined in:
- lib/ehbrs_ruby_utils/videos2/convert_job.rb
Constant Summary collapse
- FORMATS_TO_EXTENSIONS =
{ 'matroska' => '.mkv' }.freeze
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
Instance Method Summary collapse
-
#initialize(input, profile) ⇒ ConvertJob
constructor
A new instance of ConvertJob.
- #run ⇒ Object
- #target ⇒ Object
Constructor Details
#initialize(input, profile) ⇒ ConvertJob
Returns a new instance of ConvertJob.
19 20 21 22 23 24 |
# File 'lib/ehbrs_ruby_utils/videos2/convert_job.rb', line 19 def initialize(input, profile) raise "Input file \"#{input}\" does not exist" unless ::File.exist?(input.to_s) @input = input @profile = profile end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
17 18 19 |
# File 'lib/ehbrs_ruby_utils/videos2/convert_job.rb', line 17 def input @input end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
17 18 19 |
# File 'lib/ehbrs_ruby_utils/videos2/convert_job.rb', line 17 def profile @profile end |
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/ehbrs_ruby_utils/videos2/convert_job.rb', line 26 def run if ::File.exist?(converted) warn("Converted file already exist: \"#{converted}\"") else profile.run_callbacks(:convert) { convert } profile.run_callbacks(:swap) { swap } end end |
#target ⇒ Object
35 36 37 |
# File 'lib/ehbrs_ruby_utils/videos2/convert_job.rb', line 35 def target ::File.join(::File.dirname(input), "#{::File.basename(input, '.*')}#{target_extension}") end |