class WeatherSage::CLI::Commands::StationsCommand

Implementation of stations command.

Constants

COL_NAMES

CSV column names.

HELP

Help for this command.

Used by the help command.

Public Instance Methods

run(args) click to toggle source

Run stations command.

# File lib/weather-sage/cli/commands/stations.rb, line 39
def run(args)
  CSV(STDOUT) do |csv|
    # write column names
    csv << COL_NAMES

    args.each do |arg|
      # geocode argument, get first point
      if pt = geocode(arg).first
        # walk stations
        pt.point.stations.each do |s|
          csv << make_row(arg, s)
        end
      end
    end
  end
end

Private Instance Methods

make_row(address, s) click to toggle source

Convert station to CSV row.

# File lib/weather-sage/cli/commands/stations.rb, line 61
def make_row(address, s)
  [address, s.id, s.name, s.x, s.y, s.elevation, s.time_zone]
end