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
search(keyword)
click to toggle source
# File lib/ieee_paper_downloader/cli.rb, line 19 def search(keyword) result = IEEEPaperDownloader.search(keyword) articles = result['articles'].map do |article| { 'article_number' => article['article_number'], 'title' => article['title'] } end articles end