Class: NewDir
- Inherits:
-
Object
- Object
- NewDir
- Includes:
- BetterPlugin
- Defined in:
- lib/what_cd/better_plugins/new_dir.rb
Instance Method Summary collapse
- #better(context) ⇒ Object
- #description ⇒ Object
-
#determine_new_dir_name(path, quality) ⇒ Object
Intelligently decide on a new directory name.
-
#initialize ⇒ NewDir
constructor
A new instance of NewDir.
Constructor Details
#initialize ⇒ NewDir
Returns a new instance of NewDir.
9 10 11 12 13 14 15 16 17 |
# File 'lib/what_cd/better_plugins/new_dir.rb', line 9 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
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/what_cd/better_plugins/new_dir.rb', line 19 def better(context) path = context[:path] quality = context[:quality] new_path = determine_new_dir_name(path, quality) @log.info "Creating path for MP3 files at #{new_path} and copying files over" # Create the new directory if it does not exist FileUtils.cp_r path, new_path unless File.exists?(new_path) context[:path] = new_path return context end |
#description ⇒ Object
43 44 45 |
# File 'lib/what_cd/better_plugins/new_dir.rb', line 43 def description "Creates a new directory for the MP3 files that will be converted from FLAC" end |
#determine_new_dir_name(path, quality) ⇒ Object
Intelligently decide on a new directory name
33 34 35 36 37 38 39 40 41 |
# File 'lib/what_cd/better_plugins/new_dir.rb', line 33 def determine_new_dir_name(path, quality) if path.include? 'FLAC' return path.gsub 'FLAC', "MP3 #{quality}" elsif path.include? 'flac' return path.gsub! 'flac', "MP3 #{quality}" else return path.gsub! '/', " [MP3 #{quality}]" end end |