Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GetWeather
- attr_accessor :option, :token, :location
- def initialize(location,token)
- @option = option
- @token = token
- @location = location
- end
- def Results(option)
- require 'weather_underground'
- require 'pp'
- w = WeatherUnderground::Base.new(@token)
- forcast = w.forecast(@location)
- case @option
- when "station_id"
- return forcast['current_observation']['station_id']
- when "temp_c"
- return forcast['current_observation']['temp_c']
- when "feelslike_c"
- return forcast['current_observation']['feelslike_c']
- when "weather"
- return forcast['current_observation']['weather']
- when "wind_string"
- return forcast['current_observation']['wind_string']
- when "solarradiation"
- return forcast['current_observation']['solarradiation']
- else
- puts "not a proper command, Try station_id,temp_c,weather etc..."
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement