Class: Flacky::Mp3Convertor

Inherits:
Object
  • Object
show all
Defined in:
lib/flacky/mp3_convertor.rb

Defined Under Namespace

Classes: Response

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Mp3Convertor

Returns a new instance of Mp3Convertor.



12
13
14
15
# File 'lib/flacky/mp3_convertor.rb', line 12

def initialize(opts = {})
  @lame_opts = opts[:lame_opts]
  @dest_root = opts[:dest_root]
end

Instance Method Details

#convert_file!(flac_file) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/flacky/mp3_convertor.rb', line 17

def convert_file!(flac_file)
  mp3_file = calculate_mp3_filename(flac_file)

  elapsed = Benchmark.measure do
    FileUtils.mkdir_p File.dirname(mp3_file)
    transcode_file(flac_file, mp3_file)
    tag_file(flac_file, mp3_file)
  end

  Response.new(mp3_file, elapsed.real)
end