Class: Moviesort::Sorter::TV

Inherits:
Object
  • Object
show all
Defined in:
lib/moviesort/sorter.rb

Instance Method Summary collapse

Constructor Details

#initialize(output_dir) ⇒ TV



6
7
8
# File 'lib/moviesort/sorter.rb', line 6

def initialize(output_dir)
  @output_dir = output_dir
end

Instance Method Details

#sort_file(path) ⇒ Object



10
11
12
13
14
15
# File 'lib/moviesort/sorter.rb', line 10

def sort_file(path)
  tv_show = Moviesort::TVShow.parse(File.basename(path))
  target_path = File.join(@output_dir, tv_show.target_path)
  FileUtils.mkdir_p(target_path)
  FileUtils.mv(path, File.join(target_path, tv_show.target_filename))
end