Class: Convert
- Inherits:
-
Object
- Object
- Convert
- Includes:
- BetterPlugin
- Defined in:
- lib/what_cd/better_plugins/convert.rb
Instance Method Summary collapse
- #better(context) ⇒ Object
- #cleanup(path) ⇒ Object
- #convert(path, preset) ⇒ Object
- #description ⇒ Object
-
#initialize ⇒ Convert
constructor
A new instance of Convert.
Constructor Details
#initialize ⇒ Convert
Returns a new instance of Convert.
10 11 12 13 14 15 16 17 18 |
# File 'lib/what_cd/better_plugins/convert.rb', line 10 def initialize @log = Logging.logger[self] @log.appenders = Logging.appenders.stdout if $verbose @log.level = :debug else @log.level = :info end end |
Instance Method Details
#better(context) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/what_cd/better_plugins/convert.rb', line 20 def better(context) path = context[:path] quality = context[:quality] if quality == "320" convert(path, "insane") elsif quality == "V0" convert(path, "extreme") else # rage end # Remove old flac files cleanup(path) return context end |
#cleanup(path) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/what_cd/better_plugins/convert.rb', line 48 def cleanup(path) files = Dir.chdir(path) { Dir["*.flac"] } files.each do |flac_file| @log.info "Deleting #{flac_file}" FileUtils.rm_rf(path + flac_file) end end |
#convert(path, preset) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/what_cd/better_plugins/convert.rb', line 38 def convert(path, preset) files = Dir.chdir(path) { Dir["*.flac"] } files.each do |flac_file| @log.info "Converting #{flac_file}" Flac2mp3.convert(path + flac_file, :encoding => "--preset #{preset}") end end |
#description ⇒ Object
57 58 59 |
# File 'lib/what_cd/better_plugins/convert.rb', line 57 def description "Creates a new directory for the MP3 files that will be converted from FLAC" end |