Class: WeatherSage::CLI::Commands::GeocodeCommand
- Defined in:
- lib/weather-sage/cli/commands/geocode.rb
Overview
Implementation of geocode command.
Constant Summary collapse
- HELP =
Help for this command.
Used by the help command.
{ line: ' Geocode address. '.strip, full: [ 'Geocode address.', ].join("\n"), }.freeze
- CSV_COLS =
CSV columns.
%w{input_address match_address x y}
Instance Method Summary collapse
-
#run(args) ⇒ Object
Entry point for geocode command-line command.
Methods inherited from Command
Constructor Details
This class inherits a constructor from WeatherSage::CLI::Commands::Command
Instance Method Details
#run(args) ⇒ Object
Entry point for geocode command-line command.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/weather-sage/cli/commands/geocode.rb', line 31 def run(args) # create geocoder geocoder = Census::Geocoder.new(@ctx) CSV(STDOUT) do |csv| # write column headers csv << CSV_COLS # iterate command-line arguments and geocode each one args.each do |arg| # geocode argument and write results to output CSV geocoder.run(arg).each do |row| csv << [arg, row.address, row.point.x, row.point.y] end end end end |