lib/barometer/data/forecast.rb in attack-barometer-0.3.2 vs lib/barometer/data/forecast.rb in attack-barometer-0.5.0
- old
+ new
@@ -5,15 +5,17 @@
# a data class for forecasted weather conditions
#
# This is basically a data holding class for the forecasted weather
# conditions.
#
- class ForecastMeasurement
+ class Data::ForecastMeasurement
attr_reader :date, :icon, :condition
- attr_reader :low, :high, :pop, :sun
+ attr_reader :low, :high, :pop, :wind, :humidity, :sun, :night
+ # accessors (with input checking)
+ #
def date=(date)
raise ArgumentError unless date.is_a?(Date)
@date = date
end
@@ -26,33 +28,49 @@
raise ArgumentError unless condition.is_a?(String)
@condition = condition
end
def high=(high)
- raise ArgumentError unless high.is_a?(Barometer::Temperature)
+ raise ArgumentError unless high.is_a?(Data::Temperature)
@high = high
end
def low=(low)
- raise ArgumentError unless low.is_a?(Barometer::Temperature)
+ raise ArgumentError unless low.is_a?(Data::Temperature)
@low = low
end
def pop=(pop)
raise ArgumentError unless pop.is_a?(Fixnum)
@pop = pop
end
+ def wind=(wind)
+ raise ArgumentError unless wind.is_a?(Data::Speed)
+ @wind = wind
+ end
+
+ def humidity=(humidity)
+ raise ArgumentError unless humidity.is_a?(Fixnum)
+ @humidity = humidity
+ end
+
def sun=(sun)
- raise ArgumentError unless sun.is_a?(Barometer::Sun)
+ raise ArgumentError unless sun.is_a?(Data::Sun)
@sun = sun
end
+ def night=(night)
+ raise ArgumentError unless night.is_a?(Data::NightMeasurement)
+ @night = night
+ end
+
#
# helpers
#
# creates "?" helpers for all attributes (which maps to nil?)
+ #
def method_missing(method,*args)
# if the method ends in ?, then strip it off and see if we
# respond to the method without the ?
if (call_method = method.to_s.chomp!("?")) && respond_to?(call_method)
return send(call_method).nil? ? false : true
\ No newline at end of file