Created
September 22, 2012 06:56
-
-
Save taiki45/3765402 to your computer and use it in GitHub Desktop.
for blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Simple Usage | |
# creat weather object in differrnt ways | |
tokyo = WeatherJp.get :tokyo | |
tokyo = WeatherJp.get "東京都府中市" | |
minato = WeatherJp::Weather.new("東京都港区") | |
# get weather info as String | |
tokyo.today.to_s | |
#=> can be "東京都 東京の天気は曇りのち晴れ、最高気温34度...etc" | |
# to get weather info in differrnt ways | |
minato.get_weather(4) #=> <#DayWeather object> | |
minato.today.forecast #=> can be "晴れ" | |
tokyo.get_weather(:tomorrow).rain | |
minato.day_after_tomorrow.to_s | |
WeatherJp.get(:tokyo, :today).forecast | |
# use Weather object | |
tokyo.each do |w| | |
puts w.city_name | |
puts w.day | |
puts w.forecast | |
puts w.max_temp | |
puts w.min_temp | |
puts w.rain | |
w.each_pair {|k,v| puts k, v } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment