barometer 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +51 -9
- data/VERSION.yml +2 -2
- data/bin/barometer +57 -7
- data/lib/barometer.rb +11 -0
- data/lib/barometer/base.rb +3 -0
- data/lib/barometer/data.rb +11 -6
- data/lib/barometer/data/sun.rb +10 -0
- data/lib/barometer/data/zone.rb +79 -188
- data/lib/barometer/formats/coordinates.rb +4 -1
- data/lib/barometer/formats/geocode.rb +9 -7
- data/lib/barometer/formats/icao.rb +2 -2
- data/lib/barometer/formats/weather_id.rb +2 -2
- data/lib/barometer/measurements/common.rb +113 -0
- data/lib/barometer/{data → measurements}/current.rb +17 -42
- data/lib/barometer/measurements/forecast.rb +62 -0
- data/lib/barometer/measurements/forecast_array.rb +72 -0
- data/lib/barometer/{data → measurements}/measurement.rb +57 -45
- data/lib/barometer/measurements/night.rb +27 -0
- data/lib/barometer/query.rb +55 -5
- data/lib/barometer/services.rb +3 -1
- data/lib/barometer/translations/icao_country_codes.yml +274 -1
- data/lib/barometer/translations/weather_country_codes.yml +189 -6
- data/lib/barometer/translations/zone_codes.yml +360 -0
- data/lib/barometer/weather.rb +5 -4
- data/lib/barometer/weather_services/google.rb +19 -35
- data/lib/barometer/weather_services/service.rb +113 -255
- data/lib/barometer/weather_services/weather_bug.rb +291 -2
- data/lib/barometer/weather_services/weather_dot_com.rb +45 -54
- data/lib/barometer/weather_services/wunderground.rb +83 -89
- data/lib/barometer/weather_services/yahoo.rb +44 -91
- data/lib/barometer/web_services/geocode.rb +1 -0
- data/lib/barometer/web_services/timezone.rb +40 -0
- data/lib/barometer/web_services/weather_id.rb +17 -2
- data/lib/demometer/demometer.rb +28 -0
- data/lib/demometer/public/css/master.css +259 -1
- data/lib/demometer/public/css/print.css +94 -0
- data/lib/demometer/public/css/syntax.css +64 -0
- data/lib/demometer/public/images/link-out.gif +0 -0
- data/lib/demometer/views/about.erb +10 -0
- data/lib/demometer/views/index.erb +2 -0
- data/lib/demometer/views/layout.erb +3 -2
- data/lib/demometer/views/measurement.erb +4 -1
- data/lib/demometer/views/readme.erb +116 -88
- data/spec/data/sun_spec.rb +53 -0
- data/spec/data/zone_spec.rb +330 -100
- data/spec/fixtures/formats/weather_id/ksfo.xml +1 -0
- data/spec/fixtures/services/weather_bug/90210_current.xml +1 -0
- data/spec/fixtures/services/weather_bug/90210_forecast.xml +1 -0
- data/spec/formats/weather_id_spec.rb +10 -5
- data/spec/measurements/common_spec.rb +352 -0
- data/spec/{data → measurements}/current_spec.rb +40 -103
- data/spec/measurements/forecast_array_spec.rb +165 -0
- data/spec/measurements/forecast_spec.rb +135 -0
- data/spec/{data → measurements}/measurement_spec.rb +86 -107
- data/spec/measurements/night_measurement_spec.rb +49 -0
- data/spec/query_spec.rb +12 -2
- data/spec/spec_helper.rb +28 -1
- data/spec/weather_services/google_spec.rb +27 -117
- data/spec/weather_services/services_spec.rb +49 -1024
- data/spec/weather_services/weather_bug_spec.rb +274 -0
- data/spec/weather_services/weather_dot_com_spec.rb +45 -125
- data/spec/weather_services/wunderground_spec.rb +42 -136
- data/spec/weather_services/yahoo_spec.rb +26 -116
- data/spec/weather_spec.rb +45 -45
- metadata +27 -11
- data/lib/barometer/data/forecast.rb +0 -84
- data/lib/barometer/data/night.rb +0 -69
- data/lib/barometer/extensions/graticule.rb +0 -51
- data/spec/data/forecast_spec.rb +0 -192
- data/spec/data/night_measurement_spec.rb +0 -136
data/spec/weather_spec.rb
CHANGED
@@ -38,16 +38,16 @@ describe "Weather" do
|
|
38
38
|
|
39
39
|
before(:each) do
|
40
40
|
module Barometer
|
41
|
-
class
|
41
|
+
class Barometer::Measurement
|
42
42
|
attr_accessor :success
|
43
43
|
end
|
44
44
|
end
|
45
45
|
@weather = Barometer::Weather.new
|
46
|
-
@wunderground =
|
46
|
+
@wunderground = Barometer::Measurement.new(:wunderground)
|
47
47
|
@wunderground.success = true
|
48
|
-
@yahoo =
|
48
|
+
@yahoo = Barometer::Measurement.new(:yahoo)
|
49
49
|
@yahoo.success = true
|
50
|
-
@google =
|
50
|
+
@google = Barometer::Measurement.new(:google)
|
51
51
|
@weather.measurements << @wunderground
|
52
52
|
@weather.measurements << @yahoo
|
53
53
|
@weather.measurements << @google
|
@@ -82,13 +82,13 @@ describe "Weather" do
|
|
82
82
|
|
83
83
|
before(:each) do
|
84
84
|
@weather = Barometer::Weather.new
|
85
|
-
@wunderground =
|
86
|
-
@wunderground.current =
|
85
|
+
@wunderground = Barometer::Measurement.new(:wunderground)
|
86
|
+
@wunderground.current = Measurement::Current.new
|
87
87
|
@wunderground.success = true
|
88
|
-
@yahoo =
|
89
|
-
@yahoo.current =
|
88
|
+
@yahoo = Barometer::Measurement.new(:yahoo)
|
89
|
+
@yahoo.current = Measurement::Current.new
|
90
90
|
@yahoo.success = true
|
91
|
-
@google =
|
91
|
+
@google = Barometer::Measurement.new(:google)
|
92
92
|
@weather.measurements << @wunderground
|
93
93
|
@weather.measurements << @yahoo
|
94
94
|
@weather.measurements << @google
|
@@ -278,15 +278,15 @@ describe "Weather" do
|
|
278
278
|
|
279
279
|
describe "windy?" do
|
280
280
|
|
281
|
-
it "requires
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
end
|
281
|
+
# it "requires time as a Data::LocalTime object" do
|
282
|
+
# #lambda { @weather.windy?(1,"a") }.should raise_error(ArgumentError)
|
283
|
+
# lambda { @weather.windy?(1,@now) }.should_not raise_error(ArgumentError)
|
284
|
+
# end
|
286
285
|
|
287
|
-
it "requires
|
288
|
-
|
289
|
-
lambda { @weather.windy?(1
|
286
|
+
it "requires threshold as a number" do
|
287
|
+
lambda { @weather.windy?(@now,"a") }.should raise_error(ArgumentError)
|
288
|
+
lambda { @weather.windy?(@now,1) }.should_not raise_error(ArgumentError)
|
289
|
+
lambda { @weather.windy?(@now,1.1) }.should_not raise_error(ArgumentError)
|
290
290
|
end
|
291
291
|
|
292
292
|
it "returns nil when no measurements" do
|
@@ -295,20 +295,20 @@ describe "Weather" do
|
|
295
295
|
end
|
296
296
|
|
297
297
|
it "returns true if a measurement returns true" do
|
298
|
-
wunderground =
|
298
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
299
299
|
wunderground.success = true
|
300
300
|
@weather.measurements << wunderground
|
301
|
-
module Barometer; class
|
301
|
+
module Barometer; class Barometer::Measurement
|
302
302
|
def windy?(a=nil,b=nil); true; end
|
303
303
|
end; end
|
304
304
|
@weather.windy?.should be_true
|
305
305
|
end
|
306
306
|
|
307
307
|
it "returns false if a measurement returns false" do
|
308
|
-
wunderground =
|
308
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
309
309
|
wunderground.success = true
|
310
310
|
@weather.measurements << wunderground
|
311
|
-
module Barometer; class
|
311
|
+
module Barometer; class Barometer::Measurement
|
312
312
|
def windy?(a=nil,b=nil); false; end
|
313
313
|
end; end
|
314
314
|
@weather.windy?.should be_false
|
@@ -319,15 +319,15 @@ describe "Weather" do
|
|
319
319
|
describe "wet?" do
|
320
320
|
|
321
321
|
it "requires threshold as a number" do
|
322
|
-
lambda { @weather.wet?("a") }.should raise_error(ArgumentError)
|
323
|
-
lambda { @weather.wet?(1) }.should_not raise_error(ArgumentError)
|
324
|
-
lambda { @weather.wet?(1.1) }.should_not raise_error(ArgumentError)
|
322
|
+
lambda { @weather.wet?(@now,"a") }.should raise_error(ArgumentError)
|
323
|
+
lambda { @weather.wet?(@now,1) }.should_not raise_error(ArgumentError)
|
324
|
+
lambda { @weather.wet?(@now,1.1) }.should_not raise_error(ArgumentError)
|
325
325
|
end
|
326
326
|
|
327
|
-
it "requires time as a Data::LocalTime object" do
|
328
|
-
|
329
|
-
|
330
|
-
end
|
327
|
+
# it "requires time as a Data::LocalTime object" do
|
328
|
+
# #lambda { @weather.wet?(1,"a") }.should raise_error(ArgumentError)
|
329
|
+
# lambda { @weather.wet?(1,@now) }.should_not raise_error(ArgumentError)
|
330
|
+
# end
|
331
331
|
|
332
332
|
it "returns nil when no measurements" do
|
333
333
|
@weather.measurements.should be_empty
|
@@ -335,20 +335,20 @@ describe "Weather" do
|
|
335
335
|
end
|
336
336
|
|
337
337
|
it "returns true if a measurement returns true" do
|
338
|
-
wunderground =
|
338
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
339
339
|
wunderground.success = true
|
340
340
|
@weather.measurements << wunderground
|
341
|
-
module Barometer; class
|
341
|
+
module Barometer; class Barometer::Measurement
|
342
342
|
def wet?(a=nil,b=nil); true; end
|
343
343
|
end; end
|
344
344
|
@weather.wet?.should be_true
|
345
345
|
end
|
346
346
|
|
347
347
|
it "returns false if a measurement returns false" do
|
348
|
-
wunderground =
|
348
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
349
349
|
wunderground.success = true
|
350
350
|
@weather.measurements << wunderground
|
351
|
-
module Barometer; class
|
351
|
+
module Barometer; class Barometer::Measurement
|
352
352
|
def wet?(a=nil,b=nil); false; end
|
353
353
|
end; end
|
354
354
|
@weather.wet?.should be_false
|
@@ -375,10 +375,10 @@ describe "Weather" do
|
|
375
375
|
end
|
376
376
|
|
377
377
|
it "returns true if a measurement returns true (night is opposite)" do
|
378
|
-
wunderground =
|
378
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
379
379
|
wunderground.success = true
|
380
380
|
@weather.measurements << wunderground
|
381
|
-
module Barometer; class
|
381
|
+
module Barometer; class Barometer::Measurement
|
382
382
|
def day?(a=nil); true; end
|
383
383
|
end; end
|
384
384
|
@weather.day?.should be_true
|
@@ -386,10 +386,10 @@ describe "Weather" do
|
|
386
386
|
end
|
387
387
|
|
388
388
|
it "returns false if a measurement returns false (night is opposite)" do
|
389
|
-
wunderground =
|
389
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
390
390
|
wunderground.success = true
|
391
391
|
@weather.measurements << wunderground
|
392
|
-
module Barometer; class
|
392
|
+
module Barometer; class Barometer::Measurement
|
393
393
|
def day?(a=nil); false; end
|
394
394
|
end; end
|
395
395
|
@weather.day?.should be_false
|
@@ -411,40 +411,40 @@ describe "Weather" do
|
|
411
411
|
end
|
412
412
|
|
413
413
|
it "returns true if a measurement returns true" do
|
414
|
-
wunderground =
|
414
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
415
415
|
wunderground.success = true
|
416
416
|
@weather.measurements << wunderground
|
417
|
-
module Barometer; class
|
417
|
+
module Barometer; class Barometer::Measurement
|
418
418
|
def day?(a=nil); true; end
|
419
419
|
end; end
|
420
|
-
module Barometer; class
|
420
|
+
module Barometer; class Barometer::Measurement
|
421
421
|
def sunny?(a=nil,b=nil); true; end
|
422
422
|
end; end
|
423
423
|
@weather.sunny?.should be_true
|
424
424
|
end
|
425
425
|
|
426
426
|
it "returns false if a measurement returns false" do
|
427
|
-
wunderground =
|
427
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
428
428
|
wunderground.success = true
|
429
429
|
@weather.measurements << wunderground
|
430
|
-
module Barometer; class
|
430
|
+
module Barometer; class Barometer::Measurement
|
431
431
|
def day?(a=nil); true; end
|
432
432
|
end; end
|
433
|
-
module Barometer; class
|
433
|
+
module Barometer; class Barometer::Measurement
|
434
434
|
def sunny?(a=nil,b=nil); false; end
|
435
435
|
end; end
|
436
436
|
@weather.sunny?.should be_false
|
437
437
|
end
|
438
438
|
|
439
439
|
it "returns false if night time" do
|
440
|
-
wunderground =
|
440
|
+
wunderground = Barometer::Measurement.new(:wunderground)
|
441
441
|
wunderground.success = true
|
442
442
|
@weather.measurements << wunderground
|
443
|
-
module Barometer; class
|
443
|
+
module Barometer; class Barometer::Measurement
|
444
444
|
def sunny?(a=nil,b=nil); true; end
|
445
445
|
end; end
|
446
446
|
@weather.sunny?.should be_true
|
447
|
-
module Barometer; class
|
447
|
+
module Barometer; class Barometer::Measurement
|
448
448
|
def day?(a=nil); false; end
|
449
449
|
end; end
|
450
450
|
@weather.sunny?.should be_false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barometer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark G
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-15 00:00:00 -06:00
|
13
13
|
default_executable: barometer
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -29,15 +29,11 @@ files:
|
|
29
29
|
- lib/barometer
|
30
30
|
- lib/barometer/base.rb
|
31
31
|
- lib/barometer/data
|
32
|
-
- lib/barometer/data/current.rb
|
33
32
|
- lib/barometer/data/distance.rb
|
34
|
-
- lib/barometer/data/forecast.rb
|
35
33
|
- lib/barometer/data/geo.rb
|
36
34
|
- lib/barometer/data/local_datetime.rb
|
37
35
|
- lib/barometer/data/local_time.rb
|
38
36
|
- lib/barometer/data/location.rb
|
39
|
-
- lib/barometer/data/measurement.rb
|
40
|
-
- lib/barometer/data/night.rb
|
41
37
|
- lib/barometer/data/pressure.rb
|
42
38
|
- lib/barometer/data/speed.rb
|
43
39
|
- lib/barometer/data/sun.rb
|
@@ -46,7 +42,6 @@ files:
|
|
46
42
|
- lib/barometer/data/zone.rb
|
47
43
|
- lib/barometer/data.rb
|
48
44
|
- lib/barometer/extensions
|
49
|
-
- lib/barometer/extensions/graticule.rb
|
50
45
|
- lib/barometer/extensions/httparty.rb
|
51
46
|
- lib/barometer/formats
|
52
47
|
- lib/barometer/formats/coordinates.rb
|
@@ -58,11 +53,19 @@ files:
|
|
58
53
|
- lib/barometer/formats/weather_id.rb
|
59
54
|
- lib/barometer/formats/zipcode.rb
|
60
55
|
- lib/barometer/formats.rb
|
56
|
+
- lib/barometer/measurements
|
57
|
+
- lib/barometer/measurements/common.rb
|
58
|
+
- lib/barometer/measurements/current.rb
|
59
|
+
- lib/barometer/measurements/forecast.rb
|
60
|
+
- lib/barometer/measurements/forecast_array.rb
|
61
|
+
- lib/barometer/measurements/measurement.rb
|
62
|
+
- lib/barometer/measurements/night.rb
|
61
63
|
- lib/barometer/query.rb
|
62
64
|
- lib/barometer/services.rb
|
63
65
|
- lib/barometer/translations
|
64
66
|
- lib/barometer/translations/icao_country_codes.yml
|
65
67
|
- lib/barometer/translations/weather_country_codes.yml
|
68
|
+
- lib/barometer/translations/zone_codes.yml
|
66
69
|
- lib/barometer/weather.rb
|
67
70
|
- lib/barometer/weather_services
|
68
71
|
- lib/barometer/weather_services/google.rb
|
@@ -74,6 +77,7 @@ files:
|
|
74
77
|
- lib/barometer/weather_services/yahoo.rb
|
75
78
|
- lib/barometer/web_services
|
76
79
|
- lib/barometer/web_services/geocode.rb
|
80
|
+
- lib/barometer/web_services/timezone.rb
|
77
81
|
- lib/barometer/web_services/weather_id.rb
|
78
82
|
- lib/barometer/web_services/web_service.rb
|
79
83
|
- lib/barometer.rb
|
@@ -82,9 +86,13 @@ files:
|
|
82
86
|
- lib/demometer/public
|
83
87
|
- lib/demometer/public/css
|
84
88
|
- lib/demometer/public/css/master.css
|
89
|
+
- lib/demometer/public/css/print.css
|
90
|
+
- lib/demometer/public/css/syntax.css
|
85
91
|
- lib/demometer/public/images
|
86
92
|
- lib/demometer/public/images/go.png
|
93
|
+
- lib/demometer/public/images/link-out.gif
|
87
94
|
- lib/demometer/views
|
95
|
+
- lib/demometer/views/about.erb
|
88
96
|
- lib/demometer/views/contributing.erb
|
89
97
|
- lib/demometer/views/forecast.erb
|
90
98
|
- lib/demometer/views/index.erb
|
@@ -93,15 +101,11 @@ files:
|
|
93
101
|
- lib/demometer/views/readme.erb
|
94
102
|
- spec/barometer_spec.rb
|
95
103
|
- spec/data
|
96
|
-
- spec/data/current_spec.rb
|
97
104
|
- spec/data/distance_spec.rb
|
98
|
-
- spec/data/forecast_spec.rb
|
99
105
|
- spec/data/geo_spec.rb
|
100
106
|
- spec/data/local_datetime_spec.rb
|
101
107
|
- spec/data/local_time_spec.rb
|
102
108
|
- spec/data/location_spec.rb
|
103
|
-
- spec/data/measurement_spec.rb
|
104
|
-
- spec/data/night_measurement_spec.rb
|
105
109
|
- spec/data/pressure_spec.rb
|
106
110
|
- spec/data/speed_spec.rb
|
107
111
|
- spec/data/sun_spec.rb
|
@@ -114,6 +118,7 @@ files:
|
|
114
118
|
- spec/fixtures/formats/weather_id/90210.xml
|
115
119
|
- spec/fixtures/formats/weather_id/atlanta.xml
|
116
120
|
- spec/fixtures/formats/weather_id/from_USGA0028.xml
|
121
|
+
- spec/fixtures/formats/weather_id/ksfo.xml
|
117
122
|
- spec/fixtures/formats/weather_id/new_york.xml
|
118
123
|
- spec/fixtures/geocode
|
119
124
|
- spec/fixtures/geocode/40_73.xml
|
@@ -126,6 +131,9 @@ files:
|
|
126
131
|
- spec/fixtures/services
|
127
132
|
- spec/fixtures/services/google
|
128
133
|
- spec/fixtures/services/google/calgary_ab.xml
|
134
|
+
- spec/fixtures/services/weather_bug
|
135
|
+
- spec/fixtures/services/weather_bug/90210_current.xml
|
136
|
+
- spec/fixtures/services/weather_bug/90210_forecast.xml
|
129
137
|
- spec/fixtures/services/weather_dot_com
|
130
138
|
- spec/fixtures/services/weather_dot_com/90210.xml
|
131
139
|
- spec/fixtures/services/wunderground
|
@@ -142,11 +150,19 @@ files:
|
|
142
150
|
- spec/formats/short_zipcode_spec.rb
|
143
151
|
- spec/formats/weather_id_spec.rb
|
144
152
|
- spec/formats/zipcode_spec.rb
|
153
|
+
- spec/measurements
|
154
|
+
- spec/measurements/common_spec.rb
|
155
|
+
- spec/measurements/current_spec.rb
|
156
|
+
- spec/measurements/forecast_array_spec.rb
|
157
|
+
- spec/measurements/forecast_spec.rb
|
158
|
+
- spec/measurements/measurement_spec.rb
|
159
|
+
- spec/measurements/night_measurement_spec.rb
|
145
160
|
- spec/query_spec.rb
|
146
161
|
- spec/spec_helper.rb
|
147
162
|
- spec/weather_services
|
148
163
|
- spec/weather_services/google_spec.rb
|
149
164
|
- spec/weather_services/services_spec.rb
|
165
|
+
- spec/weather_services/weather_bug_spec.rb
|
150
166
|
- spec/weather_services/weather_dot_com_spec.rb
|
151
167
|
- spec/weather_services/wunderground_spec.rb
|
152
168
|
- spec/weather_services/yahoo_spec.rb
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
module Barometer
|
3
|
-
#
|
4
|
-
# Forecast Measurement
|
5
|
-
# a data class for forecasted weather conditions
|
6
|
-
#
|
7
|
-
# This is basically a data holding class for the forecasted weather
|
8
|
-
# conditions.
|
9
|
-
#
|
10
|
-
class Data::ForecastMeasurement
|
11
|
-
|
12
|
-
attr_reader :date, :icon, :condition
|
13
|
-
attr_reader :low, :high, :pop, :wind, :humidity, :sun, :night
|
14
|
-
|
15
|
-
# accessors (with input checking)
|
16
|
-
#
|
17
|
-
def date=(date)
|
18
|
-
raise ArgumentError unless date.is_a?(Date)
|
19
|
-
@date = date
|
20
|
-
end
|
21
|
-
|
22
|
-
def icon=(icon)
|
23
|
-
raise ArgumentError unless icon.is_a?(String)
|
24
|
-
@icon = icon
|
25
|
-
end
|
26
|
-
|
27
|
-
def condition=(condition)
|
28
|
-
raise ArgumentError unless condition.is_a?(String)
|
29
|
-
@condition = condition
|
30
|
-
end
|
31
|
-
|
32
|
-
def high=(high)
|
33
|
-
raise ArgumentError unless high.is_a?(Data::Temperature)
|
34
|
-
@high = high
|
35
|
-
end
|
36
|
-
|
37
|
-
def low=(low)
|
38
|
-
raise ArgumentError unless low.is_a?(Data::Temperature)
|
39
|
-
@low = low
|
40
|
-
end
|
41
|
-
|
42
|
-
def pop=(pop)
|
43
|
-
raise ArgumentError unless pop.is_a?(Fixnum)
|
44
|
-
@pop = pop
|
45
|
-
end
|
46
|
-
|
47
|
-
def wind=(wind)
|
48
|
-
raise ArgumentError unless wind.is_a?(Data::Speed)
|
49
|
-
@wind = wind
|
50
|
-
end
|
51
|
-
|
52
|
-
def humidity=(humidity)
|
53
|
-
raise ArgumentError unless humidity.is_a?(Fixnum)
|
54
|
-
@humidity = humidity
|
55
|
-
end
|
56
|
-
|
57
|
-
def sun=(sun)
|
58
|
-
raise ArgumentError unless sun.is_a?(Data::Sun)
|
59
|
-
@sun = sun
|
60
|
-
end
|
61
|
-
|
62
|
-
def night=(night)
|
63
|
-
raise ArgumentError unless night.is_a?(Data::NightMeasurement)
|
64
|
-
@night = night
|
65
|
-
end
|
66
|
-
|
67
|
-
#
|
68
|
-
# helpers
|
69
|
-
#
|
70
|
-
|
71
|
-
# creates "?" helpers for all attributes (which maps to nil?)
|
72
|
-
#
|
73
|
-
def method_missing(method,*args)
|
74
|
-
# if the method ends in ?, then strip it off and see if we
|
75
|
-
# respond to the method without the ?
|
76
|
-
if (call_method = method.to_s.chomp!("?")) && respond_to?(call_method)
|
77
|
-
return send(call_method).nil? ? false : true
|
78
|
-
else
|
79
|
-
super(method,*args)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
data/lib/barometer/data/night.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
module Barometer
|
3
|
-
#
|
4
|
-
# Night Measurement
|
5
|
-
# a data class for forecasted night weather conditions
|
6
|
-
#
|
7
|
-
# This is basically a data holding class for the forecasted night
|
8
|
-
# weather conditions.
|
9
|
-
#
|
10
|
-
class Data::NightMeasurement
|
11
|
-
|
12
|
-
attr_reader :date, :icon, :condition
|
13
|
-
attr_reader :pop, :wind, :humidity
|
14
|
-
|
15
|
-
# accessors (with input checking)
|
16
|
-
#
|
17
|
-
def date=(date)
|
18
|
-
raise ArgumentError unless date.is_a?(Date)
|
19
|
-
@date = date
|
20
|
-
end
|
21
|
-
|
22
|
-
def icon=(icon)
|
23
|
-
raise ArgumentError unless icon.is_a?(String)
|
24
|
-
@icon = icon
|
25
|
-
end
|
26
|
-
|
27
|
-
def condition=(condition)
|
28
|
-
raise ArgumentError unless condition.is_a?(String)
|
29
|
-
@condition = condition
|
30
|
-
end
|
31
|
-
|
32
|
-
def pop=(pop)
|
33
|
-
raise ArgumentError unless pop.is_a?(Fixnum)
|
34
|
-
@pop = pop
|
35
|
-
end
|
36
|
-
|
37
|
-
def wind=(wind)
|
38
|
-
raise ArgumentError unless wind.is_a?(Data::Speed)
|
39
|
-
@wind = wind
|
40
|
-
end
|
41
|
-
|
42
|
-
def humidity=(humidity)
|
43
|
-
raise ArgumentError unless humidity.is_a?(Fixnum)
|
44
|
-
@humidity = humidity
|
45
|
-
end
|
46
|
-
|
47
|
-
def sun=(sun)
|
48
|
-
raise ArgumentError unless sun.is_a?(Data::Sun)
|
49
|
-
@sun = sun
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# helpers
|
54
|
-
#
|
55
|
-
|
56
|
-
# creates "?" helpers for all attributes (which maps to nil?)
|
57
|
-
#
|
58
|
-
def method_missing(method,*args)
|
59
|
-
# if the method ends in ?, then strip it off and see if we
|
60
|
-
# respond to the method without the ?
|
61
|
-
if (call_method = method.to_s.chomp!("?")) && respond_to?(call_method)
|
62
|
-
return send(call_method).nil? ? false : true
|
63
|
-
else
|
64
|
-
super(method,*args)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|