Class: Pandata::CLI
- Inherits:
-
Object
- Object
- Pandata::CLI
- Defined in:
- lib/pandata/cli.rb
Overview
Pandata command-line interface
Class Method Summary collapse
Instance Method Summary collapse
- #download_and_output ⇒ Object
-
#initialize(options) ⇒ CLI
constructor
A new instance of CLI.
- #update_progress(new_data) ⇒ Object
Constructor Details
#initialize(options) ⇒ CLI
Returns a new instance of CLI.
24 25 26 27 28 29 30 31 |
# File 'lib/pandata/cli.rb', line 24 def initialize() @data_to_get = [:data_to_get] @output_file = [:output_file] @return_as_json = [:return_as_json] @scraper = scraper_for([:user_id]) @scraper.download_cb = method(:update_progress) end |
Class Method Details
.scrape(argv) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pandata/cli.rb', line 12 def self.scrape(argv) = Pandata::ArgvParser.parse(argv) if argv.empty? || [:help] puts [:opts].to_s # Log usage information elsif [:version] puts Pandata::Version::STRING else new().download_and_output end end |
Instance Method Details
#download_and_output ⇒ Object
37 38 39 |
# File 'lib/pandata/cli.rb', line 37 def download_and_output output_data format_data(download_data, @return_as_json) end |
#update_progress(new_data) ⇒ Object
33 34 35 |
# File 'lib/pandata/cli.rb', line 33 def update_progress(new_data) .progress += new_data.size end |