Class: PRSS::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/prss/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(passkey, output_dir) ⇒ CLI

Returns a new instance of CLI.



5
6
7
8
9
10
# File 'lib/prss/cli.rb', line 5

def initialize passkey, output_dir
  @passkey = passkey
  @output_dir = Pathname.new(output_dir)
  raise 'no passkey' unless passkey
  raise 'no output dir' unless output_dir
end

Instance Method Details

#run!Object



12
13
14
15
16
17
18
19
# File 'lib/prss/cli.rb', line 12

def run!
  output = Fetcher.new(@passkey).output
  links = Parser.new(output)
  downloaded = Downloader.new(links).download_to(@output_dir)

  puts "Downloaded #{downloaded.count} files to #{@output_dir}."
  puts "Files:", *downloaded unless downloaded.empty?
end