Class: Paperclip::FfmpegWav2Mp3
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::FfmpegWav2Mp3
- Defined in:
- lib/paperclip-wav-mp3.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#format ⇒ Object
Returns the value of attribute format.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ FfmpegWav2Mp3
constructor
A new instance of FfmpegWav2Mp3.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ FfmpegWav2Mp3
8 9 10 11 12 13 14 15 |
# File 'lib/paperclip-wav-mp3.rb', line 8 def initialize(file, = {}, = nil) super @file = file @params = [:params] @current_format = File.extname(@file.path) @basename = File.basename(@file.path, @current_format) @format = [:format] end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
6 7 8 |
# File 'lib/paperclip-wav-mp3.rb', line 6 def file @file end |
#format ⇒ Object
Returns the value of attribute format.
6 7 8 |
# File 'lib/paperclip-wav-mp3.rb', line 6 def format @format end |
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/paperclip-wav-mp3.rb', line 6 def params @params end |
Instance Method Details
#make ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/paperclip-wav-mp3.rb', line 17 def make src = @file dst = Tempfile.new([@basename, @format ? ".#{@format}" : '' ]) begin parameters = [] parameters << @params parameters << ":source" parameters << ":dest" parameters = parameters.flatten.compact.join(' ').strip.squeeze(' ') success = Paperclip.run('ffmpeg', parameters, :source => File.(src.path), :dest => File.(dst.path)) rescue PaperclipCommandLineError => e raise PaperclipError, "There was an error converting #{@basename} to mp3" end dst end |