Sha256: 4d9a115c1023fa5b7da00eed31f763c521f6afe396117e8e440dce5c7c8ee765
Contents?: true
Size: 966 Bytes
Versions: 1
Compression:
Stored size: 966 Bytes
Contents
require "thor" require 'meteo/meteo' require 'meteo/geo' require 'meteo/weather_reporter' class MeteoCLI < Thor desc "quote location", "quote weather for location" long_desc <<-LONGDESC `meteo` will print weather quote for requested city. You can optionally specify a second parameter, which will print out a from message as well. > $ meteo Plainsboro, NJ > $ meteo Moscow, RU --units=metric > $ meteo # get weather for current location based on IP address LONGDESC option :units, :aliases => "-u" option :forecast def quote(location) location = (location.nil? or location.strip.size == 0) ? Geo.new.quote : location units = options[:units] ? options[:units] : "imperial" forecast = options[:forecast] ? options[:forecast].to_i : 0 service = Meteo.new(forecast > 0) response = service.quote(location, units) reporter = WeatherReporter.new reporter.report(response, units, forecast) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
meteo-1.1.0 | lib/meteo/meteo_cli.rb |