Class: MovieOrganizer::Movie
- Defined in:
- lib/movie_organizer/movie.rb
Instance Attribute Summary
Attributes inherited from Media
#filename, #logger, #options, #settings
Instance Method Summary collapse
-
#initialize(filename, options) ⇒ Movie
constructor
A new instance of Movie.
- #process! ⇒ Object
- #processed_filename ⇒ Object
- #title ⇒ Object
Methods inherited from Media
#movie?, subtype, #tv_show?, #year
Constructor Details
#initialize(filename, options) ⇒ Movie
Returns a new instance of Movie.
8 9 10 |
# File 'lib/movie_organizer/movie.rb', line 8 def initialize(filename, ) super end |
Instance Method Details
#process! ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/movie_organizer/movie.rb', line 12 def process! target_dir = File.join(MovieOrganizer.movie_directory, "#{title} (#{year})") target_file = File.join(target_dir, processed_filename) # logger.info(" target dir: [#{target_dir}]") logger.info(" target file: [#{target_file.green.bold}]") fc = FileCopier.new(filename, target_file, ) fc.copy end |
#processed_filename ⇒ Object
21 22 23 |
# File 'lib/movie_organizer/movie.rb', line 21 def processed_filename "#{title} (#{year})#{ext}" end |
#title ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/movie_organizer/movie.rb', line 25 def title ext_regex = Regexp.new(ext.sub(/\./, '\\.')) newbase = sanitize( basename.sub(/#{ext_regex}$/, '').sub(/\(?#{year}\)?/, '') ) @title ||= newbase end |