Class: Zippy::CLI

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

Instance Method Summary collapse

Instance Method Details

#batch(file, n = 0) ⇒ Object



17
18
19
20
# File 'lib/zippy/cli.rb', line 17

def batch(file, n = 0)
  links = File.readlines(file).each.map(&:strip)
  Parallel.each(links, in_threads: n.to_i) { |link| download(link) }
end

#download(url) ⇒ Object



11
12
13
14
# File 'lib/zippy/cli.rb', line 11

def download(url)
  down_url = Zippy::Parser.parse(url)
  system format('wget -cq --show-progress %s', Shellwords.escape(down_url))
end