class IEEEPaperDownloader::CLI

Constants

INTERVAL

Public Instance Methods

csv(csv_file_path) click to toggle source
# File lib/ieee_paper_downloader/cli.rb, line 13
def csv(csv_file_path)
  articles = IEEEPaperDownloader.read_csv(csv_file_path)
  download_paper(articles)
end
download(keyword) click to toggle source
# File lib/ieee_paper_downloader/cli.rb, line 7
def download(keyword)
  articles = search(keyword)
  download_paper(articles)
end
download_paper(articles, interval = INTERVAL) click to toggle source
# File lib/ieee_paper_downloader/cli.rb, line 30
def download_paper(articles, interval = INTERVAL)
  articles.each do |article|
    filename = "#{article['title']}.pdf"
    if File.exist?(filename)
      puts "Already downloaded \"#{article['title']}\"\n"
    else
      puts "Downloading \"#{article['title']}\"\n"
      IEEEPaperDownloader.download(article['article_number'], filename)
      puts "Sleep #{interval}sec"
      sleep interval
    end
  end
end