barometer 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +7 -0
  3. data/LICENSE +1 -1
  4. data/{README.rdoc → README.md} +124 -110
  5. data/Rakefile +1 -21
  6. data/TODO +8 -9
  7. data/barometer.gemspec +20 -19
  8. data/bin/barometer +36 -83
  9. data/lib/barometer.rb +13 -11
  10. data/lib/barometer/base.rb +10 -10
  11. data/lib/barometer/data.rb +1 -1
  12. data/lib/barometer/data/distance.rb +25 -25
  13. data/lib/barometer/data/geo.rb +9 -9
  14. data/lib/barometer/data/local_datetime.rb +24 -20
  15. data/lib/barometer/data/local_time.rb +13 -13
  16. data/lib/barometer/data/location.rb +6 -6
  17. data/lib/barometer/data/pressure.rb +24 -24
  18. data/lib/barometer/data/speed.rb +28 -28
  19. data/lib/barometer/data/sun.rb +7 -7
  20. data/lib/barometer/data/temperature.rb +29 -29
  21. data/lib/barometer/data/units.rb +9 -9
  22. data/lib/barometer/data/zone.rb +19 -19
  23. data/lib/barometer/formats.rb +1 -1
  24. data/lib/barometer/formats/coordinates.rb +7 -7
  25. data/lib/barometer/formats/format.rb +6 -6
  26. data/lib/barometer/formats/geocode.rb +5 -5
  27. data/lib/barometer/formats/icao.rb +6 -6
  28. data/lib/barometer/formats/postalcode.rb +3 -3
  29. data/lib/barometer/formats/short_zipcode.rb +2 -2
  30. data/lib/barometer/formats/weather_id.rb +10 -10
  31. data/lib/barometer/formats/woe_id.rb +20 -20
  32. data/lib/barometer/formats/zipcode.rb +3 -3
  33. data/lib/barometer/key_file_parser.rb +20 -0
  34. data/lib/barometer/measurements/measurement.rb +32 -32
  35. data/lib/barometer/measurements/result.rb +39 -39
  36. data/lib/barometer/measurements/result_array.rb +12 -12
  37. data/lib/barometer/query.rb +15 -15
  38. data/lib/barometer/services.rb +3 -3
  39. data/lib/barometer/translations/icao_country_codes.yml +20 -20
  40. data/lib/barometer/translations/weather_country_codes.yml +1 -1
  41. data/lib/barometer/translations/zone_codes.yml +2 -2
  42. data/lib/barometer/version.rb +3 -0
  43. data/lib/barometer/weather.rb +27 -27
  44. data/lib/barometer/weather_services/noaa.rb +314 -3
  45. data/lib/barometer/weather_services/service.rb +32 -30
  46. data/lib/barometer/weather_services/weather_bug.rb +35 -33
  47. data/lib/barometer/weather_services/wunderground.rb +31 -29
  48. data/lib/barometer/weather_services/yahoo.rb +36 -35
  49. data/lib/barometer/web_services/geocode.rb +5 -7
  50. data/lib/barometer/web_services/noaa_station_id.rb +53 -0
  51. data/lib/barometer/web_services/placemaker.rb +11 -13
  52. data/lib/barometer/web_services/timezone.rb +5 -7
  53. data/lib/barometer/web_services/weather_id.rb +4 -6
  54. data/lib/barometer/web_services/web_service.rb +4 -4
  55. data/spec/barometer_spec.rb +25 -27
  56. data/spec/cassettes/Barometer.json +1 -0
  57. data/spec/cassettes/Query.json +1 -0
  58. data/spec/cassettes/Query_Format_Coordinates.json +1 -0
  59. data/spec/cassettes/Query_Format_Geocode.json +1 -0
  60. data/spec/cassettes/Query_Format_WeatherID.json +1 -0
  61. data/spec/cassettes/Query_Format_WoeID.json +1 -0
  62. data/spec/cassettes/WeatherService.json +1 -0
  63. data/spec/cassettes/WeatherService_Noaa.json +1 -0
  64. data/spec/cassettes/WeatherService_WeatherBug.json +1 -0
  65. data/spec/cassettes/WeatherService_Wunderground.json +1 -0
  66. data/spec/cassettes/WeatherService_Yahoo.json +1 -0
  67. data/spec/cassettes/WebService_Geocode.json +1 -0
  68. data/spec/cassettes/WebService_NoaaStation.json +1 -0
  69. data/spec/data/distance_spec.rb +60 -60
  70. data/spec/data/geo_spec.rb +23 -23
  71. data/spec/data/local_datetime_spec.rb +44 -44
  72. data/spec/data/local_time_spec.rb +47 -47
  73. data/spec/data/location_spec.rb +16 -16
  74. data/spec/data/pressure_spec.rb +61 -61
  75. data/spec/data/speed_spec.rb +69 -69
  76. data/spec/data/sun_spec.rb +25 -25
  77. data/spec/data/temperature_spec.rb +68 -68
  78. data/spec/data/units_spec.rb +21 -21
  79. data/spec/data/zone_spec.rb +35 -35
  80. data/spec/formats/coordinates_spec.rb +27 -27
  81. data/spec/formats/format_spec.rb +17 -25
  82. data/spec/formats/geocode_spec.rb +23 -31
  83. data/spec/formats/icao_spec.rb +26 -32
  84. data/spec/formats/postalcode_spec.rb +22 -28
  85. data/spec/formats/short_zipcode_spec.rb +20 -26
  86. data/spec/formats/weather_id_spec.rb +57 -67
  87. data/spec/formats/woe_id_spec.rb +59 -59
  88. data/spec/formats/zipcode_spec.rb +39 -47
  89. data/spec/key_file_parser_spec.rb +28 -0
  90. data/spec/measurements/measurement_spec.rb +79 -133
  91. data/spec/measurements/result_array_spec.rb +23 -38
  92. data/spec/measurements/result_spec.rb +100 -128
  93. data/spec/query_spec.rb +83 -100
  94. data/spec/spec_helper.rb +24 -6
  95. data/spec/weather_services/noaa_spec.rb +179 -0
  96. data/spec/weather_services/services_spec.rb +28 -36
  97. data/spec/weather_services/weather_bug_spec.rb +57 -77
  98. data/spec/weather_services/wunderground_spec.rb +36 -65
  99. data/spec/weather_services/yahoo_spec.rb +38 -60
  100. data/spec/weather_spec.rb +79 -79
  101. data/spec/web_services/geocode_spec.rb +7 -11
  102. data/spec/web_services/noaa_station_id_spec.rb +33 -0
  103. data/spec/web_services/placemaker_spec.rb +7 -12
  104. data/spec/web_services/web_services_spec.rb +3 -9
  105. metadata +214 -163
  106. data/VERSION.yml +0 -5
  107. data/lib/barometer/weather_services/google.rb +0 -142
  108. data/lib/barometer/weather_services/weather_dot_com.rb +0 -279
  109. data/spec/fakeweb_helper.rb +0 -179
  110. data/spec/fixtures/formats/weather_id/90210.xml +0 -7
  111. data/spec/fixtures/formats/weather_id/from_USGA0028.xml +0 -3
  112. data/spec/fixtures/formats/weather_id/ksfo.xml +0 -1
  113. data/spec/fixtures/formats/weather_id/manhattan.xml +0 -7
  114. data/spec/fixtures/formats/weather_id/new_york.xml +0 -1
  115. data/spec/fixtures/formats/weather_id/the_hills.xml +0 -1
  116. data/spec/fixtures/geocode/40_73_v3.json +0 -497
  117. data/spec/fixtures/geocode/90210_v3.json +0 -63
  118. data/spec/fixtures/geocode/T5B4M9_v3.json +0 -68
  119. data/spec/fixtures/geocode/atlanta_v3.json +0 -58
  120. data/spec/fixtures/geocode/calgary_ab_v3.json +0 -58
  121. data/spec/fixtures/geocode/ksfo_v3.json +0 -73
  122. data/spec/fixtures/geocode/newyork_ny_v3.json +0 -58
  123. data/spec/fixtures/services/google/calgary_ab.xml +0 -1
  124. data/spec/fixtures/services/placemaker/T5B4M9.xml +0 -65
  125. data/spec/fixtures/services/placemaker/atlanta.xml +0 -65
  126. data/spec/fixtures/services/placemaker/coords.xml +0 -65
  127. data/spec/fixtures/services/placemaker/ksfo.xml +0 -65
  128. data/spec/fixtures/services/placemaker/new_york.xml +0 -65
  129. data/spec/fixtures/services/placemaker/the_hills.xml +0 -65
  130. data/spec/fixtures/services/placemaker/w615702.xml +0 -47
  131. data/spec/fixtures/services/weather_bug/90210_current.xml +0 -93
  132. data/spec/fixtures/services/weather_bug/90210_forecast.xml +0 -76
  133. data/spec/fixtures/services/weather_dot_com/90210.xml +0 -1
  134. data/spec/fixtures/services/wunderground/current_calgary_ab.xml +0 -9
  135. data/spec/fixtures/services/wunderground/forecast_calgary_ab.xml +0 -13
  136. data/spec/fixtures/services/yahoo/90210.xml +0 -3
  137. data/spec/weather_services/google_spec.rb +0 -181
  138. data/spec/weather_services/weather_dot_com_spec.rb +0 -224
@@ -7,16 +7,16 @@ module Barometer
7
7
  # with methods for insertion and searching
8
8
  #
9
9
  class Measurement::ResultArray < Array
10
-
10
+
11
11
  def <<(forecast)
12
12
  raise ArgumentError unless forecast.is_a?(Measurement::Result)
13
13
  super(forecast)
14
14
  end
15
-
15
+
16
16
  def [](index)
17
17
  index.is_a?(Fixnum) ? super(index) : self.for(index)
18
18
  end
19
-
19
+
20
20
  #
21
21
  # Returns a forecast for a day given by a Date, DateTime,
22
22
  # Time, or a string that can be parsed to a Data::LocalDateTime
@@ -24,9 +24,9 @@ module Barometer
24
24
  # credit: http://github.com/jdpace/weatherman/
25
25
  #
26
26
  def for(datetime)
27
-
27
+
28
28
  return nil unless self.size > 0
29
-
29
+
30
30
  # Format date into a Date class
31
31
  datetime = case datetime.class.name
32
32
  when 'Date'
@@ -41,35 +41,35 @@ module Barometer
41
41
  when 'DateTime'
42
42
  Data::LocalDateTime.parse(datetime)
43
43
  end
44
-
44
+
45
45
  day = nil
46
46
  self.each do |f|
47
47
  day = f if f.for_datetime?(datetime)
48
48
  end
49
49
  return day
50
50
  end
51
-
51
+
52
52
  #
53
53
  # answer simple questions
54
54
  #
55
-
55
+
56
56
  def windy?(datetime, threshold=10)
57
57
  (forecast = self[datetime]) ? forecast.windy?(threshold) : nil
58
58
  end
59
-
59
+
60
60
  def day?(datetime)
61
61
  local_time = Data::LocalTime.parse(datetime)
62
62
  (forecast = self[datetime]) ? forecast.day?(local_time) : nil
63
63
  end
64
-
64
+
65
65
  def sunny?(datetime, sunny_icons=nil)
66
66
  local_time = Data::LocalTime.parse(datetime)
67
67
  (forecast = self[datetime]) ? forecast.sunny?(local_time, sunny_icons) : nil
68
68
  end
69
-
69
+
70
70
  def wet?(datetime, wet_icons=nil, pop_threshold=50, humidity_threshold=99)
71
71
  (forecast = self[datetime]) ? forecast.wet?(wet_icons,pop_threshold,humidity_threshold) : nil
72
72
  end
73
-
73
+
74
74
  end
75
75
  end
@@ -17,7 +17,7 @@ module Barometer
17
17
  # not accept the query string.
18
18
  #
19
19
  class Query
20
-
20
+
21
21
  # This array defines the order to check a query for the format
22
22
  #
23
23
  FORMATS = %w(
@@ -29,18 +29,18 @@ module Barometer
29
29
  :coordinates => "Coordinates", :icao => "Icao",
30
30
  :woe_id => "WoeID", :geocode => "Geocode"
31
31
  }
32
-
32
+
33
33
  attr_writer :q
34
34
  attr_accessor :format, :country_code
35
35
  attr_accessor :geo, :timezone, :conversions
36
-
36
+
37
37
  def initialize(query=nil)
38
38
  return unless query
39
39
  @q = query
40
40
  self.analyze!
41
41
  @conversions = {}
42
42
  end
43
-
43
+
44
44
  def q
45
45
  format ? Barometer::Query::Format.const_get(FORMAT_MAP[format.to_sym].to_s).convert_query(@q) : @q
46
46
  end
@@ -59,14 +59,14 @@ module Barometer
59
59
  end
60
60
  end
61
61
  end
62
-
62
+
63
63
  # take a list of acceptable (and ordered by preference) formats and convert
64
64
  # the current query (q) into the most preferred and acceptable format. a
65
65
  # side effect of the conversions may reveal the country_code, if so save it
66
66
  #
67
67
  def convert!(preferred_formats=nil)
68
68
  raise ArgumentError unless (preferred_formats && preferred_formats.size > 0)
69
-
69
+
70
70
  # why convert if we are already there?
71
71
  # (except in the case that the serivce excepts coordinates and we have a
72
72
  # a geocode ... the google geocode results are superior)
@@ -79,7 +79,7 @@ module Barometer
79
79
  converted_query = self.dup
80
80
  end
81
81
  end
82
-
82
+
83
83
  unless skip_conversion
84
84
  # go through each acceptable format and try to convert to that
85
85
  converted = false
@@ -94,7 +94,7 @@ module Barometer
94
94
  unless converted
95
95
  unless converted_query = get_conversion(preferred_format)
96
96
  converted_query = Query::Format.const_get(klass.to_s).to(self)
97
- end
97
+ end
98
98
  converted = true if converted_query
99
99
  end
100
100
  if converted
@@ -104,7 +104,7 @@ module Barometer
104
104
  end
105
105
  end
106
106
  end
107
-
107
+
108
108
  # force geocode?, unless we already did
109
109
  #
110
110
  if Barometer.force_geocode && !@geo
@@ -117,7 +117,7 @@ module Barometer
117
117
  converted_query.geo = @geo.dup
118
118
  end
119
119
  end
120
-
120
+
121
121
  # enhance timezone?, unless we already did
122
122
  #
123
123
  if Barometer.enhance_timezone && !@timezone
@@ -129,10 +129,10 @@ module Barometer
129
129
  converted_query.timezone = @timezone.dup
130
130
  end
131
131
  end
132
-
132
+
133
133
  converted_query
134
134
  end
135
-
135
+
136
136
  # save the important parts of the conversion ... by saving conversion we
137
137
  # can avoid doing the same conversion multiple times
138
138
  #
@@ -162,11 +162,11 @@ end
162
162
  return nil unless self.format == Query::Format::Coordinates.format
163
163
  Query::Format::Coordinates.parse_latitude(self.q)
164
164
  end
165
-
165
+
166
166
  def longitude
167
167
  return nil unless self.format == Query::Format::Coordinates.format
168
168
  Query::Format::Coordinates.parse_longitude(self.q)
169
169
  end
170
-
170
+
171
171
  end
172
- end
172
+ end
@@ -4,10 +4,9 @@ $:.unshift(File.dirname(__FILE__))
4
4
  #
5
5
  require 'weather_services/service'
6
6
  require 'weather_services/wunderground'
7
- require 'weather_services/google'
8
7
  require 'weather_services/yahoo'
9
- require 'weather_services/weather_dot_com'
10
8
  require 'weather_services/weather_bug'
9
+ require 'weather_services/noaa'
11
10
 
12
11
  #
13
12
  # web services (non weather)
@@ -16,4 +15,5 @@ require 'web_services/web_service'
16
15
  require 'web_services/geocode'
17
16
  require 'web_services/weather_id'
18
17
  require 'web_services/timezone'
19
- require 'web_services/placemaker'
18
+ require 'web_services/placemaker'
19
+ require 'web_services/noaa_station_id'
@@ -11,18 +11,18 @@ one_letter:
11
11
  U : RU
12
12
  Y : AU
13
13
  Z : CN
14
-
14
+
15
15
  two_letter:
16
16
  # A - Western South Pacific
17
17
  AG : SB
18
18
  AN : NR
19
19
  AY : PG
20
-
20
+
21
21
  # B - Iceland/Greenland and Kosovo
22
22
  BG : GL
23
23
  BI : IS
24
24
  #BK : Kosovo (also LY Serbia (RS) because of disputes)
25
-
25
+
26
26
  # D - West Africa
27
27
  DA : DZ
28
28
  DB : BJ
@@ -33,7 +33,7 @@ two_letter:
33
33
  DR : NE
34
34
  DT : TN
35
35
  # DX : Togolese Republic
36
-
36
+
37
37
  # E - Northern Europe
38
38
  EB : BE
39
39
  ED : DE
@@ -50,7 +50,7 @@ two_letter:
50
50
  ET : DE
51
51
  EV : LV
52
52
  EY : LT
53
-
53
+
54
54
  # F - Southern Africa
55
55
  FA : ZA
56
56
  FB : BW
@@ -75,7 +75,7 @@ two_letter:
75
75
  FX : LS
76
76
  FY : NA
77
77
  FZ : CD
78
-
78
+
79
79
  # G - Northwestern Africa
80
80
  GA : ML
81
81
  GB : GM
@@ -90,7 +90,7 @@ two_letter:
90
90
  GS : EH
91
91
  GU : GN
92
92
  GV : CV
93
-
93
+
94
94
  # H - Northeastern Africa
95
95
  HA : ET
96
96
  HB : BI
@@ -105,7 +105,7 @@ two_letter:
105
105
  HS : SD
106
106
  HT : TZ
107
107
  HU : UG
108
-
108
+
109
109
  # L - Southern Europe,Israel and Turkey
110
110
  LA : AL
111
111
  LB : BG
@@ -133,7 +133,7 @@ two_letter:
133
133
  LX : GI
134
134
  #LY : Serbia (RS) and Montenegro (ME)
135
135
  LZ : SK
136
-
136
+
137
137
  # M - Central America and Mexico
138
138
  MB : TC
139
139
  MD : DO
@@ -150,7 +150,7 @@ two_letter:
150
150
  MW : KY
151
151
  MY : BS
152
152
  MZ : BZ
153
-
153
+
154
154
  # N - South Pacific
155
155
  NC : CK
156
156
  # NF : Fiji (FJ), Tonga (TO)
@@ -162,7 +162,7 @@ two_letter:
162
162
  NV : VU
163
163
  NW : NC
164
164
  # NZ : New Zealand (NZ), Antarctica (AQ)
165
-
165
+
166
166
  # O - Southwest Asia (excluding Israel and Turkey), Afghanistan and Pakistan
167
167
  OA : AF
168
168
  OB : BH
@@ -178,7 +178,7 @@ two_letter:
178
178
  OS : SY
179
179
  OT : QA
180
180
  OY : YE
181
-
181
+
182
182
  # P - Eastern North Pacific
183
183
  PA : US
184
184
  # PB : Baker Island
@@ -194,14 +194,14 @@ two_letter:
194
194
  PP : US
195
195
  # PT : Federated States of Micronesia (FM), Palau (PW)
196
196
  # PW : Wake Island
197
-
197
+
198
198
  # R - Western North Pacific
199
199
  RC : TW
200
200
  RJ : JP
201
201
  RK : KR
202
202
  RO : JP
203
203
  RP : PH
204
-
204
+
205
205
  # S - South America
206
206
  SA : AR
207
207
  SB : BR
@@ -221,7 +221,7 @@ two_letter:
221
221
  SV : VE
222
222
  SW : BR
223
223
  SY : GY
224
-
224
+
225
225
  # T - Caribbean
226
226
  TA : AG
227
227
  TB : BB
@@ -239,7 +239,7 @@ two_letter:
239
239
  TU : VG
240
240
  TV : VC
241
241
  TX : BM
242
-
242
+
243
243
  # U - Russia and former Soviet States
244
244
  UA : KZ
245
245
  UB : AZ
@@ -248,7 +248,7 @@ two_letter:
248
248
  UK : UA
249
249
  UM : BY
250
250
  #UT Tajikistan (TJ), Turkmenistan (TM), Uzbekistan (UZ)
251
-
251
+
252
252
  # V - South Asia (except Afghanistan and Pakistan) and mainland Southeast Asia
253
253
  VA : IN
254
254
  VC : LK
@@ -266,7 +266,7 @@ two_letter:
266
266
  VT : TH
267
267
  VV : VN
268
268
  VY : MM
269
-
269
+
270
270
  # W - Maritime Southeast Asia (except the Philippines)
271
271
  WA : ID
272
272
  # WB : Malaysia (MY), Brunei (BN)
@@ -276,7 +276,7 @@ two_letter:
276
276
  WQ : ID
277
277
  WR : ID
278
278
  WS : SG
279
-
279
+
280
280
  # Z - China, Mongolia and North Korea
281
281
  ZK : KP
282
- ZM : MN
282
+ ZM : MN
@@ -197,4 +197,4 @@ ZI : ZW
197
197
  ### Marshall Islands USMH : MH
198
198
  ### American Samoa USAS : AS
199
199
  ### Palau USPW : PW
200
- ### Guam USGU : GU
200
+ ### Guam USGU : GU
@@ -265,7 +265,7 @@ SLST : -3
265
265
  SRT : -3
266
266
  SST : -11
267
267
  SYST : 3
268
- SWT : 1
268
+ SWT : 1
269
269
  SYT : 2
270
270
 
271
271
  T : -7
@@ -357,4 +357,4 @@ YEKST : 6
357
357
  YEKT : 5
358
358
  YST : -9
359
359
 
360
- Z : 0
360
+ Z : 0
@@ -0,0 +1,3 @@
1
+ module Barometer
2
+ VERSION = '0.8.0'
3
+ end
@@ -6,19 +6,19 @@ module Barometer
6
6
  # methods to interact with the data
7
7
  #
8
8
  class Weather
9
-
9
+
10
10
  attr_accessor :measurements
11
11
  attr_accessor :start_at, :end_at
12
-
12
+
13
13
  def initialize; @measurements = []; end
14
-
14
+
15
15
  # the default measurement is the first successful measurement
16
16
  #
17
17
  def default
18
18
  return nil unless self.sources
19
19
  self.source(self.sources.first)
20
20
  end
21
-
21
+
22
22
  # find the measurement for the given source, if it exists
23
23
  #
24
24
  def source(source)
@@ -28,32 +28,32 @@ module Barometer
28
28
  end
29
29
  nil
30
30
  end
31
-
31
+
32
32
  # list successful sources
33
33
  #
34
34
  def sources
35
35
  @measurements.collect {|m| m.source.to_sym if m.success?}.compact
36
36
  end
37
-
37
+
38
38
  #
39
39
  # Quick access methods
40
40
  #
41
-
41
+
42
42
  def metric?; self.default ? self.default.metric? : true; end
43
43
  def current; (default = self.default) ? default.current : nil; end
44
44
  def forecast; (default = self.default) ? default.forecast : nil; end
45
45
  def now; self.current; end
46
-
46
+
47
47
  def today
48
48
  default = self.default
49
49
  default && default.forecast ? default.forecast[0] : nil
50
50
  end
51
-
51
+
52
52
  def tomorrow
53
53
  default = self.default
54
54
  default && default.forecast ? default.forecast[1] : nil
55
55
  end
56
-
56
+
57
57
  # measurement search
58
58
  # this will search the default measurements forecasts looking for
59
59
  # the matching date
@@ -62,19 +62,19 @@ module Barometer
62
62
  default = self.default
63
63
  default && default.forecast ? default.for(query) : nil
64
64
  end
65
-
66
-
65
+
66
+
67
67
  #
68
68
  # helper methods
69
69
  #
70
70
  # these are handy methods that can average values for successful weather
71
71
  # sources, or answer a simple question (ie: weather.windy?)
72
72
  #
73
-
73
+
74
74
  #
75
75
  # averages
76
76
  #
77
-
77
+
78
78
  # this assumes calculating for current, and that "to_f" for a value
79
79
  # will return the value needed
80
80
  # value_name = the name of the value we are averaging
@@ -97,7 +97,7 @@ module Barometer
97
97
  return nil unless values && values.size > 0
98
98
  values.inject(0.0) { |sum,v| sum += v if v } / values.size
99
99
  end
100
-
100
+
101
101
  def average(value_name, do_average=true, class_name=nil)
102
102
  if class_name
103
103
  if do_average
@@ -111,7 +111,7 @@ module Barometer
111
111
  end
112
112
  avg
113
113
  end
114
-
114
+
115
115
  # average of all values
116
116
  #
117
117
  def humidity(do_average=true); average("humidity",do_average); end
@@ -122,29 +122,29 @@ module Barometer
122
122
  def heat_index(do_average=true); average("heat_index",do_average,"Temperature"); end
123
123
  def wind_chill(do_average=true); average("wind_chill",do_average,"Temperature"); end
124
124
  def visibility(do_average=true); average("visibility",do_average,"Distance"); end
125
-
125
+
126
126
  #
127
127
  # quick access methods
128
128
  #
129
-
129
+
130
130
  # what is the current local time and date?
131
131
  # def time
132
132
  # end
133
-
133
+
134
134
  # def icon
135
135
  # self.current.icon
136
136
  # end
137
-
137
+
138
138
  #
139
139
  # simple questions
140
140
  # pass the question on to each successful measurement until we get an answer
141
141
  #
142
-
142
+
143
143
  def windy?(time_string=nil, threshold=10)
144
144
  local_datetime = Data::LocalDateTime.parse(time_string)
145
145
  raise ArgumentError unless (threshold.is_a?(Fixnum) || threshold.is_a?(Float))
146
146
  raise ArgumentError unless (local_datetime.nil? || local_datetime.is_a?(Data::LocalDateTime))
147
-
147
+
148
148
  is_windy = nil
149
149
  @measurements.each do |measurement|
150
150
  if measurement.success?
@@ -159,7 +159,7 @@ module Barometer
159
159
  local_datetime = Data::LocalDateTime.parse(time_string)
160
160
  raise ArgumentError unless (threshold.is_a?(Fixnum) || threshold.is_a?(Float))
161
161
  raise ArgumentError unless (local_datetime.nil? || local_datetime.is_a?(Data::LocalDateTime))
162
-
162
+
163
163
  is_wet = nil
164
164
  @measurements.each do |measurement|
165
165
  if measurement.success?
@@ -173,7 +173,7 @@ module Barometer
173
173
  def day?(time_string=nil)
174
174
  local_datetime = Data::LocalDateTime.parse(time_string)
175
175
  raise ArgumentError unless (local_datetime.nil? || local_datetime.is_a?(Data::LocalDateTime))
176
-
176
+
177
177
  is_day = nil
178
178
  @measurements.each do |measurement|
179
179
  if measurement.success?
@@ -194,7 +194,7 @@ module Barometer
194
194
  def sunny?(time_string=nil)
195
195
  local_datetime = Data::LocalDateTime.parse(time_string)
196
196
  raise ArgumentError unless (local_datetime.nil? || local_datetime.is_a?(Data::LocalDateTime))
197
-
197
+
198
198
  is_sunny = nil
199
199
  @measurements.each do |measurement|
200
200
  if measurement.success?
@@ -207,5 +207,5 @@ module Barometer
207
207
  end
208
208
 
209
209
  end
210
-
211
- end
210
+
211
+ end