class WeatherSage::CLI::Commands::GeocodeCommand

Implementation of geocode command.

Constants

CSV_COLS

CSV columns.

HELP

Help for this command.

Used by the help command.

Public Instance Methods

run(args) click to toggle source

Entry point for geocode command-line command.

# 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