public
Description: Ruby gem for accessing the Weather Channel XML API
Homepage: http://codewordstudios.com
Clone URL: git://github.com/jdpace/weatherman.git
weatherman / README.rdoc
039b635b » jdpace 2008-09-29 changed README to rdoc. See... 1 = WeatherMan
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 2
3 A Ruby Gem that wraps the Weather Channel, inc. XML data feed
4 written by Jared Pace, Codeword: Studios (http://codewordstudios.com),
039b635b » jdpace 2008-09-29 changed README to rdoc. See... 5 based on the rweather[http://github.com/ckozus/rweather] gem by Carlos Kozuszko - http://www.ckozus.com.ar/blog/.
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 6
039b635b » jdpace 2008-09-29 changed README to rdoc. See... 7 == Dependencies
dbf90f3b » jdpace 2008-09-29 Added tracking of promotion... 8
039b635b » jdpace 2008-09-29 changed README to rdoc. See... 9 1. XmlSimple
700162a3 » jdpace 2008-09-29 Fix too many indents in rdoc 10 `gem install xml-simple`
dbf90f3b » jdpace 2008-09-29 Added tracking of promotion... 11
039b635b » jdpace 2008-09-29 changed README to rdoc. See... 12 ---------------------------
13
14 == Installation
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 15
16
700162a3 » jdpace 2008-09-29 Fix too many indents in rdoc 17 % sudo gem sources -a http://gems.github.com # (if you haven't already)
03b64e73 » jdpace 2008-09-29 Fix README.rdoc to show cor... 18 % sudo gem install jdpace-weatherman
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 19
039b635b » jdpace 2008-09-29 changed README to rdoc. See... 20 ---------------------------
21
22 == Usage
23
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 24
25 Find or load a location:
26
700162a3 » jdpace 2008-09-29 Fix too many indents in rdoc 27 require 'weather_man'
28 WeatherMan.partner_id = '0123456789'
29 WeatherMan.license_key = '0123456789abcdef'
30
31 # Search for a location
32 # Returns an array of WeatherMan objects
33 locations = WeatherMan.search('New York')
34
35 # or if you know the location id or just want to use a US Zip code
36 ny = WeatherMan.new('USNY0996')
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 37
38 Fetch the weather:
39
700162a3 » jdpace 2008-09-29 Fix too many indents in rdoc 40 # Fetch the current conditions and 5 day forecast in 'standard' units
41 weather = ny.fetch
42
43 # Fetch only current conditions in metric units
44 weather = ny.fetch(:days => 0, :unit => 'm')
45
46 # Fetch a 3 day forecast only
47 weather = ny.fetch(:days => 3, :current_conditions => false)
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 48
49 Look at the Current Conditions:
50
700162a3 » jdpace 2008-09-29 Fix too many indents in rdoc 51 # current temperature
52 temp = weather.current_conditions.temperature
53
54 feels_like = weather.current_conditions.feels_like
55
56 wind_speed = weather.current_conditions.wind.speed
57 wind_direction = weather.current_conditions.wind.direction
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 58
59 Look at the forecast:
700162a3 » jdpace 2008-09-29 Fix too many indents in rdoc 60
61 # how many days?
62 weather.forecast.size
63
64 # Some different forecasts
65 weather.forecast.today
66 weather.forecast.tomorrow
67 weather.forecast.monday
68 weather.forecast.for(Date.today)
69 weather.forecast.for(3.days.from_now) # Note: using rails core extensions
70 weather.forecast.for('Sep 1')
71
72 # data for a forecast
73 friday = weather.forecast.friday
74
75 high_temp = friday.high
76 low_temp = friday.low
77
78 # forecasts are split into 2 parts day/night
79 friday.day.description # Partly Cloudy, Sunny...
80 friday.day.chance_percipitation # 0..100
81
82 night_wind_speed = friday.night.wind.speed
1745a63a » jdpace 2008-09-29 Finished 0.1 version with d... 83
dbf90f3b » jdpace 2008-09-29 Added tracking of promotion... 84 The Weather Channel requires that you 4 promotional links for them if you use their service. Here's how to access those links:
700162a3 » jdpace 2008-09-29 Fix too many indents in rdoc 85
86 # The array of pr links
87 weather.links
88
89 # Getting the first links text and url
90 weather.links.first.text
91 weather.links.first.url
dbf90f3b » jdpace 2008-09-29 Added tracking of promotion... 92
039b635b » jdpace 2008-09-29 changed README to rdoc. See... 93 TODO: Document all attributes