Class: Moviesort::CommandLine

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ CommandLine

Returns a new instance of CommandLine.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/moviesort/command_line.rb', line 10

def initialize(argv = ARGV)
  @options = Trollop.options(argv) do
    banner "    Moviesort is a script to sort and file away your TV shows and movies\n\n    Usage: moviesort [options]\n    EOS\n\n    opt :source, \"Source directory\", :default => '.'\n    opt :target, \"Target directory\", :default => '.'\n  end\nend\n".gsub(/^ {8}/, '')

Class Method Details

.parse(options) ⇒ Object



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

def self.parse(options)
  new(options.split)
end

Instance Method Details

#runObject



23
24
25
26
27
28
# File 'lib/moviesort/command_line.rb', line 23

def run
  sorter = Sorter::TV.new(@options[:target])
  Dir[File.join(@options[:source], '*.avi')].each do |file|
    sorter.sort_file(file)
  end
end