Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Capture the weather locations local time in the response object.

  • Loading branch information...
commit 7541bc6445cec385b40a5a6d98309a0dca27efe6 1 parent 91f16fd
Jared Pace authored
7 lib/weather_man_response.rb
View
@@ -1,7 +1,9 @@
require 'ostruct'
+require 'date'
+require 'time'
class WeatherManResponse
- attr_reader :current_conditions, :forecast, :api_url, :unit_temperature, :unit_distance, :unit_speed, :unit_pressure, :links
+ attr_reader :current_conditions, :forecast, :api_url, :unit_temperature, :unit_distance, :unit_speed, :unit_pressure, :links, :local_time
def initialize(simple_xml, url = nil)
@current_conditions = simple_xml['cc'] ? build_current_conditions(simple_xml['cc'][0]) : nil
@@ -16,6 +18,9 @@ def initialize(simple_xml, url = nil)
@unit_speed = simple_xml['head'][0]['us'][0]
@unit_pressure = simple_xml['head'][0]['up'][0]
+ # Capture some location info
+ @local_time = Time.parse(simple_xml['loc'][0]['tm'][0])
+
# The api url that was called to generate this response
@api_url = url
end
4 spec/weather_man_response_spec.rb
View
@@ -15,6 +15,10 @@
@weather.unit_pressure.should eql('in')
end
+ it 'should grab the local time' do
+ @weather.local_time.should == Time.parse('7:17 PM')
+ end
+
it 'should build a CurrentConditions object' do
@weather.current_conditions.should be_kind_of(WeatherManCurrentConditions)
end
4 weatherman.gemspec
View
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = "weatherman"
- s.version = "0.1.1"
- s.date = "2008-09-29"
+ s.version = "0.1.2"
+ s.date = "2008-10-03"
s.homepage = "http://github.com/jdpace/weatherman"
s.summary = "Ruby gem for accessing the Weather Channel XML API based on rweather."
Please sign in to comment.
Something went wrong with that request. Please try again.