yahoo_weatherForcast

a little Ruby Gem for fetching weather’s data from Yahoo! Weather API using YQL


How to use?

first you should make an instance of Weather class:

#You can initialize this class with name of country & city that you want like example in below
YahooWeatherForecast::Weather.new(country: 'iran', city: 'tehran')
#or initialize this class with WOEID of location you want like example in below:
YahooWeatherForecast::Weather.new(woeid: '2251945')

both of these initialization ways give you an object that has several method that provide you some useful data:

#first we initialize Weather class
holder = YahooWeatherForecast::Weather.new(country: 'iran', city: 'tehran')

#this returns a hash about location of object as structure in below:
#{"city"=>"Tehran", "country"=>"Iran", "region"=>" Tehran"}
holder.getLocation

#this returns a hash about wind blowing in that location as structure in below:
#{"chill"=>"88", "direction"=>"248", "speed"=>"11"}
holder.getWind

#this returns a hash about Atmosphere state in that location as structure in below:
#{"humidity"=>"25", "pressure"=>"867.0", "rising"=>"0", "visibility"=>"16.1"}
holder.getAtmosphere

#this returns a hash of sunrise & sunset times in that location as structure in below:
#{"sunrise"=>"5:54 am", "sunset"=>"8:24 pm"}
holder.getAstronomy

#this returns Publish Date of this data about that location as structure in below:
#"Mon, 04 Jul 2016 11:30 AM IRDT"
holder.getPublishDate

#this returns some general weather's data about that location at a 10 day period
#you can give it a day index between 0 to 9 (default day index is 0) and get data as structure in below:
#{"code"=>"32", "date"=>"06 Jul 2016", "day"=>"Wed", "high"=>"100", "low"=>"76", "text"=>"Sunny"}
holder.getForecast(2)