-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on updating happy mapper to include options
Signed-off-by: John Nunemaker <nunemaker@gmail.com>
- Loading branch information
1 parent
f4018f0
commit c0aa03a
Showing
3 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
require File.join(dir, 'happymapper') | ||
|
||
file_contents = File.read(dir + '/../spec/fixtures/current_weather.xml') | ||
|
||
class CurrentWeather | ||
include HappyMapper | ||
tag 'aws:ob' | ||
element :temperature, Integer, :tag => 'aws:temp' | ||
element :feels_like, Integer, :tag => 'aws:feels-like' | ||
element :current_condition, String, :tag => 'aws:current-condition', :attributes => {:icon => String} | ||
end | ||
|
||
CurrentWeather.parse(file_contents).each do |current_weather| | ||
puts "temperature: #{current_weather.temperature}" | ||
puts "feels_like: #{current_weather.feels_like}" | ||
puts "current_condition: #{current_weather.current_condition}" | ||
puts "current_condition.icon: #{current_weather.current_condition.icon}" | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<aws:weather xmlns:aws="http://www.aws.com/aws"> | ||
<aws:api version="2.0"/> | ||
<aws:WebURL>http://weather.weatherbug.com/IN/Carmel-weather.html?ZCode=Z5546&Units=0&stat=MOCAR</aws:WebURL> | ||
<aws:ob> | ||
<aws:ob-date> | ||
<aws:year number="2008"/> | ||
<aws:month number="12" text="December" abbrv="Dec"/> | ||
<aws:day number="30" text="Tuesday" abbrv="Tue"/> | ||
<aws:hour number="4" hour-24="16"/> | ||
<aws:minute number="18"/> | ||
<aws:second number="01"/> | ||
<aws:am-pm abbrv="PM"/> | ||
<aws:time-zone offset="-5" text="Eastern Standard Time" abbrv="EST"/> | ||
</aws:ob-date> | ||
<aws:requested-station-id>mocar</aws:requested-station-id> | ||
<aws:station-id>MOCAR</aws:station-id> | ||
<aws:station>Mohawk Trail ES</aws:station> | ||
<aws:city-state zipcode="46033">Carmel, IN</aws:city-state> | ||
<aws:country>USA</aws:country> | ||
<aws:latitude>39.9711111111111</aws:latitude> | ||
<aws:longitude>-86.0938888888889</aws:longitude> | ||
<aws:site-url>http://www1.ccs.k12.in.us/mte/home</aws:site-url> | ||
<aws:aux-temp units="&deg;F">74</aws:aux-temp> | ||
<aws:aux-temp-rate units="&deg;F">+0.0</aws:aux-temp-rate> | ||
<aws:current-condition icon="http://deskwx.weatherbug.com/images/Forecast/icons/cond007.gif">Sunny</aws:current-condition> | ||
<aws:dew-point units="&deg;F">35</aws:dew-point> | ||
<aws:elevation units="ft">817</aws:elevation> | ||
<aws:feels-like units="&deg;F">51</aws:feels-like> | ||
<aws:gust-time> | ||
<aws:year number="0001"/> | ||
<aws:month number="1" text="January" abbrv="Jan"/> | ||
<aws:day number="1" text="Monday" abbrv="Mon"/> | ||
<aws:hour number="12" hour-24="00"/> | ||
<aws:minute number="00"/> | ||
<aws:second number="00"/> | ||
<aws:am-pm abbrv="AM"/> | ||
<aws:time-zone offset="-5" text="Eastern Standard Time" abbrv="EST"/> | ||
</aws:gust-time> | ||
<aws:gust-direction>W</aws:gust-direction> | ||
<aws:gust-speed units="mph">25</aws:gust-speed> | ||
<aws:humidity units="%">53</aws:humidity> | ||
<aws:humidity-high units="%">100.0</aws:humidity-high> | ||
<aws:humidity-low units="%">42.5</aws:humidity-low> | ||
<aws:humidity-rate>-5.0</aws:humidity-rate> | ||
<aws:indoor-temp units="&deg;F">75</aws:indoor-temp> | ||
<aws:indoor-temp-rate units="&deg;F">+0.0</aws:indoor-temp-rate> | ||
<aws:light>28</aws:light> | ||
<aws:light-rate>-1.5</aws:light-rate> | ||
<aws:moon-phase moon-phase-img="http://api.wxbug.net/images/moonphase/mphase02.gif">-10</aws:moon-phase> | ||
<aws:pressure units=""">29.71</aws:pressure> | ||
<aws:pressure-high units=""">30.18</aws:pressure-high> | ||
<aws:pressure-low units=""">29.71</aws:pressure-low> | ||
<aws:pressure-rate units=""/h">-0.04</aws:pressure-rate> | ||
<aws:rain-month units=""">6.64</aws:rain-month> | ||
<aws:rain-rate units=""/h">0.00</aws:rain-rate> | ||
<aws:rain-rate-max units=""/h">0.00</aws:rain-rate-max> | ||
<aws:rain-today units=""">0.00</aws:rain-today> | ||
<aws:rain-year units=""">53.83</aws:rain-year> | ||
<aws:temp units="&deg;F">51.8</aws:temp> | ||
<aws:temp-high units="&deg;F">52</aws:temp-high> | ||
<aws:temp-low units="&deg;F">29</aws:temp-low> | ||
<aws:temp-rate units="&deg;F/h">+2.5</aws:temp-rate> | ||
<aws:sunrise> | ||
<aws:year number="2008"/> | ||
<aws:month number="12" text="December" abbrv="Dec"/> | ||
<aws:day number="30" text="Tuesday" abbrv="Tue"/> | ||
<aws:hour number="8" hour-24="08"/> | ||
<aws:minute number="06"/> | ||
<aws:second number="02"/> | ||
<aws:am-pm abbrv="AM"/> | ||
<aws:time-zone offset="-5" text="Eastern Standard Time" abbrv="EST"/> | ||
</aws:sunrise> | ||
<aws:sunset> | ||
<aws:year number="2008"/> | ||
<aws:month number="12" text="December" abbrv="Dec"/> | ||
<aws:day number="30" text="Tuesday" abbrv="Tue"/> | ||
<aws:hour number="5" hour-24="17"/> | ||
<aws:minute number="28"/> | ||
<aws:second number="53"/> | ||
<aws:am-pm abbrv="PM"/> | ||
<aws:time-zone offset="-5" text="Eastern Standard Time" abbrv="EST"/> | ||
</aws:sunset> | ||
<aws:wet-bulb units="&deg;F">44.24</aws:wet-bulb> | ||
<aws:wind-speed units="mph">4</aws:wind-speed> | ||
<aws:wind-speed-avg units="mph">7</aws:wind-speed-avg> | ||
<aws:wind-direction>SSW</aws:wind-direction> | ||
<aws:wind-direction-avg>SW</aws:wind-direction-avg> | ||
</aws:ob> | ||
</aws:weather> |