class WeatherByDcq::Request
export
Attributes
location[RW]
Public Class Methods
coordinate_pts(location)
click to toggle source
Convert user entered location to geodetic coordinates
# File lib/weather_by_dcq/request.rb, line 18 def self.coordinate_pts(location) city = Geocoder.search(location) if city[0].nil? puts "Not Found" return WeatherByDcq::View.new.menu else @lat = city[0].latitude @lon = city[0].longitude end end
fetch(location)
click to toggle source
fetch forecast hash from Dark Sky API
# File lib/weather_by_dcq/request.rb, line 30 def self.fetch(location) coordinate_pts(location) ForecastIO.configure do |c| c.api_key = '4aac124157c348289553a5e7fdc1899d' c.default_params = { time: 600, exclude: 'minutely, hourly' } end @forecast = ForecastIO.forecast(@lat, @lon) end
new(location)
click to toggle source
# File lib/weather_by_dcq/request.rb, line 13 def initialize(location) @location = location end