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
@@ -1,22 +1,22 @@
1
1
  module Barometer
2
2
  class Base
3
-
3
+
4
4
  # allow the configuration of specific weather APIs to be used,
5
5
  # and the order in which they would be used
6
6
  #
7
7
  @@config = { 1 => [:wunderground] }
8
8
  def self.config; @@config; end;
9
9
  def self.config=(hash); @@config = hash; end;
10
-
10
+
11
11
  attr_reader :query
12
12
  attr_accessor :weather, :success
13
-
13
+
14
14
  def initialize(query=nil)
15
15
  @query = Barometer::Query.new(query)
16
16
  @weather = Barometer::Weather.new
17
17
  @success = false
18
18
  end
19
-
19
+
20
20
  # iterate through all the configured sources and
21
21
  # collect weather data for each one
22
22
  #
@@ -33,15 +33,15 @@ module Barometer
33
33
  end
34
34
  level += 1
35
35
  end
36
-
36
+
37
37
  @weather.end_at = Time.now.utc
38
38
  @weather
39
39
  end
40
-
40
+
41
41
  def success?; @success; end
42
-
42
+
43
43
  private
44
-
44
+
45
45
  # iterate through the setup until we have a source name (and possibly
46
46
  # a config for that source), then measure with that source
47
47
  #
@@ -66,7 +66,7 @@ module Barometer
66
66
  end
67
67
  end
68
68
  end
69
-
69
+
70
70
  # do that actual source measurement
71
71
  #
72
72
  def _measure(datum, config=nil, metric=nil)
@@ -80,4 +80,4 @@ module Barometer
80
80
  end
81
81
 
82
82
  end
83
- end
83
+ end
@@ -18,4 +18,4 @@ require 'data/local_datetime'
18
18
  #
19
19
  require 'measurements/measurement'
20
20
  require 'measurements/result'
21
- require 'measurements/result_array'
21
+ require 'measurements/result_array'
@@ -1,51 +1,51 @@
1
1
  module Barometer
2
2
  #
3
3
  # A simple Distance class
4
- #
4
+ #
5
5
  # Think of this like the Integer class. Enhancement
6
6
  # is that you can create a number (in a certain unit), then
7
7
  # get that number back already converted to another unit.
8
8
  #
9
9
  # All comparison operations will be done in metric
10
- #
10
+ #
11
11
  # NOTE: this currently only supports the scale of
12
12
  # kilometers (km) and miles (m). There is currently
13
13
  # no way to scale to smaller units (eg km -> m -> mm)
14
14
  #
15
15
  class Data::Distance < Data::Units
16
-
16
+
17
17
  METRIC_UNITS = "km"
18
18
  IMPERIAL_UNITS = "m"
19
-
19
+
20
20
  attr_accessor :kilometers, :miles
21
-
21
+
22
22
  def initialize(metric=true)
23
23
  @kilometers = nil
24
24
  @miles = nil
25
25
  super(metric)
26
26
  end
27
-
27
+
28
28
  def metric_default=(value); self.km = value; end
29
29
  def imperial_default=(value); self.m = value; end
30
30
 
31
31
  #
32
32
  # CONVERTERS
33
33
  #
34
-
34
+
35
35
  def self.km_to_m(km)
36
36
  return nil unless km && (km.is_a?(Integer) || km.is_a?(Float))
37
37
  km.to_f * 0.622
38
38
  end
39
-
39
+
40
40
  def self.m_to_km(m)
41
41
  return nil unless m && (m.is_a?(Integer) || m.is_a?(Float))
42
42
  m.to_f * 1.609
43
43
  end
44
-
44
+
45
45
  #
46
46
  # ACCESSORS
47
47
  #
48
-
48
+
49
49
  # store kilometers
50
50
  #
51
51
  def km=(km)
@@ -53,7 +53,7 @@ module Barometer
53
53
  @kilometers = km.to_f
54
54
  self.update_miles(km.to_f)
55
55
  end
56
-
56
+
57
57
  # store miles
58
58
  #
59
59
  def m=(m)
@@ -61,57 +61,57 @@ module Barometer
61
61
  @miles = m.to_f
62
62
  self.update_kilometers(m.to_f)
63
63
  end
64
-
64
+
65
65
  # return the stored kilometers or convert from miles
66
66
  #
67
67
  def km(as_integer=true)
68
68
  km = (@kilometers || Data::Distance.m_to_km(@miles))
69
69
  km ? (as_integer ? km.to_i : (100*km).round/100.0) : nil
70
70
  end
71
-
71
+
72
72
  # return the stored miles or convert from kilometers
73
73
  #
74
74
  def m(as_integer=true)
75
75
  m = (@miles || Data::Distance.km_to_m(@kilometers))
76
76
  m ? (as_integer ? m.to_i : (100*m).round/100.0) : nil
77
77
  end
78
-
78
+
79
79
  #
80
80
  # OPERATORS
81
81
  #
82
-
82
+
83
83
  def <=>(other)
84
84
  self.km <=> other.km
85
85
  end
86
-
86
+
87
87
  #
88
88
  # HELPERS
89
89
  #
90
-
90
+
91
91
  # will just return the value (no units)
92
92
  #
93
93
  def to_i(metric=nil)
94
94
  (metric || (metric.nil? && self.metric?)) ? self.km : self.m
95
95
  end
96
-
96
+
97
97
  # will just return the value (no units) with more precision
98
98
  #
99
99
  def to_f(metric=nil)
100
100
  (metric || (metric.nil? && self.metric?)) ? self.km(false) : self.m(false)
101
101
  end
102
-
102
+
103
103
  # will return the value with units
104
104
  #
105
105
  def to_s(metric=nil)
106
106
  (metric || (metric.nil? && self.metric?)) ? "#{self.km} #{METRIC_UNITS}" : "#{self.m} #{IMPERIAL_UNITS}"
107
107
  end
108
-
108
+
109
109
  # will just return the units (no value)
110
110
  #
111
111
  def units(metric=nil)
112
112
  (metric || (metric.nil? && self.metric?)) ? METRIC_UNITS : IMPERIAL_UNITS
113
113
  end
114
-
114
+
115
115
  # when we set miles, it is possible the a non-equivalent value of
116
116
  # kilometers remains. if so, clear it.
117
117
  def update_kilometers(m)
@@ -121,7 +121,7 @@ module Barometer
121
121
  # then the conversion of miles
122
122
  @kilometers = nil unless difference.abs <= 1.0
123
123
  end
124
-
124
+
125
125
  # when we set kilometers, it is possible the a non-equivalent value of
126
126
  # miles remains. if so, clear it.
127
127
  #
@@ -132,10 +132,10 @@ module Barometer
132
132
  # then the conversion of kilometers
133
133
  @miles = nil unless difference.abs <= 1.0
134
134
  end
135
-
135
+
136
136
  def nil?
137
137
  (@kilometers || @miles) ? false : true
138
138
  end
139
-
139
+
140
140
  end
141
- end
141
+ end
@@ -1,30 +1,30 @@
1
1
  module Barometer
2
2
  #
3
3
  # A simple Geo class
4
- #
4
+ #
5
5
  # Used to store location data
6
6
  #
7
7
  class Data::Geo
8
-
8
+
9
9
  attr_accessor :latitude, :longitude, :query
10
10
  attr_accessor :locality, :region, :country, :country_code, :address
11
-
11
+
12
12
  def initialize(location=nil)
13
13
  return unless location
14
14
  raise ArgumentError unless location.is_a?(Hash)
15
15
  self.build_from_hash(location)
16
16
  self
17
17
  end
18
-
18
+
19
19
  def build_from_hash(location=nil)
20
20
  return nil unless location
21
21
  raise ArgumentError unless location.is_a?(Hash)
22
-
22
+
23
23
  if location["geometry"] && location["geometry"]["location"]
24
24
  @latitude = location["geometry"]["location"]["lat"].to_f
25
25
  @longitude = location["geometry"]["location"]["lng"].to_f
26
26
  end
27
-
27
+
28
28
  query_parts = []
29
29
  if location["address_components"]
30
30
  location["address_components"].each do |address_components|
@@ -49,7 +49,7 @@ module Barometer
49
49
  end
50
50
  end
51
51
  end
52
-
52
+
53
53
  @query = query_parts.join(', ')
54
54
  @address = ""
55
55
  end
@@ -57,7 +57,7 @@ module Barometer
57
57
  def coordinates
58
58
  [@latitude, @longitude].join(',')
59
59
  end
60
-
60
+
61
61
  def to_s
62
62
  s = [@address, @locality, @region, @country || @country_code]
63
63
  s.delete("")
@@ -65,4 +65,4 @@ module Barometer
65
65
  end
66
66
 
67
67
  end
68
- end
68
+ end
@@ -2,12 +2,12 @@ require 'date'
2
2
  module Barometer
3
3
  #
4
4
  # A simple DateTime class
5
- #
5
+ #
6
6
  # A time class that represents the local date_time ...
7
7
  # it has no concept of time zone
8
8
  #
9
9
  class Data::LocalDateTime < Data::LocalTime
10
-
10
+
11
11
  attr_reader :year, :month, :day
12
12
 
13
13
  def initialize(y,mon,d,h=0,m=0,s=0)
@@ -18,31 +18,31 @@ module Barometer
18
18
  super(h,m,s)
19
19
  self
20
20
  end
21
-
21
+
22
22
  def year=(y)
23
23
  unless y && y.is_a?(Fixnum) && Date.civil(y,@month,@day)
24
24
  raise(ArgumentError, "invalid year")
25
25
  end
26
26
  @year = y
27
27
  end
28
-
28
+
29
29
  def month=(m)
30
30
  unless m && m.is_a?(Fixnum) && Date.civil(@year,m,@day)
31
31
  raise(ArgumentError, "invalid month")
32
32
  end
33
33
  @month = m
34
34
  end
35
-
35
+
36
36
  def day=(d)
37
37
  unless d && d.is_a?(Fixnum) && Date.civil(@year,@month,d)
38
38
  raise(ArgumentError, "invalid day")
39
39
  end
40
40
  @day = d
41
41
  end
42
-
43
- def parse(string)
42
+
43
+ def parse(string, format=nil)
44
44
  return unless string
45
- new_date = Data::LocalDateTime.parse(string)
45
+ new_date = Data::LocalDateTime.parse(string, format)
46
46
  @year = new_date.year
47
47
  @month = new_date.month
48
48
  @day = new_date.day
@@ -51,11 +51,11 @@ module Barometer
51
51
  @sec = new_date.sec
52
52
  self
53
53
  end
54
-
55
- def self.parse(string)
54
+
55
+ def self.parse(string, format=nil)
56
56
  return nil unless string
57
57
  return string if string.is_a?(Data::LocalDateTime)
58
-
58
+
59
59
  year = nil; month = nil; day = nil;
60
60
  hour = nil; min = nil; sec = nil;
61
61
  if string.is_a?(Time) || string.is_a?(DateTime)
@@ -71,7 +71,11 @@ module Barometer
71
71
  day = string.day
72
72
  elsif string.is_a?(String)
73
73
  begin
74
- datetime = Time.parse(string)
74
+ datetime = if format
75
+ Time.strptime(string, format)
76
+ else
77
+ DateTime.parse(string)
78
+ end
75
79
  year = datetime.year
76
80
  month = datetime.mon
77
81
  day = datetime.day
@@ -84,19 +88,19 @@ module Barometer
84
88
  end
85
89
  Data::LocalDateTime.new(year, month, day, hour, min, sec)
86
90
  end
87
-
91
+
88
92
  # convert to a Date class
89
93
  #
90
94
  def to_d
91
95
  Date.civil(@year, @month, @day)
92
96
  end
93
-
97
+
94
98
  # convert to a DateTime class
95
99
  #
96
100
  def to_dt
97
101
  DateTime.new(@year, @month, @day, @hour, @min, @sec)
98
102
  end
99
-
103
+
100
104
  def <=>(other)
101
105
  if other.is_a?(String) || other.is_a?(Time) || other.is_a?(DateTime) || other.is_a?(Date)
102
106
  the_other = Data::LocalDateTime.parse(other)
@@ -104,7 +108,7 @@ module Barometer
104
108
  the_other = other
105
109
  end
106
110
  raise ArgumentError unless the_other.is_a?(Data::LocalDateTime) || the_other.is_a?(Data::LocalTime)
107
-
111
+
108
112
  if ((other.is_a?(String) || other.is_a?(Time) || other.is_a?(DateTime)) &&
109
113
  the_other.is_a?(Data::LocalDateTime)) || other.is_a?(Data::LocalDateTime)
110
114
  # we are counting days + seconds
@@ -121,21 +125,21 @@ module Barometer
121
125
  return total_seconds <=> the_other.total_seconds
122
126
  end
123
127
  end
124
-
128
+
125
129
  def to_s(time=false)
126
130
  datetime = self.to_dt
127
131
  format = (time ? "%Y-%m-%d %I:%M:%S %p" : "%Y-%m-%d")
128
132
  datetime.strftime(format).downcase
129
133
  end
130
-
134
+
131
135
  def nil?; @year == 0 && @month == 0 && @day == 0 && super; end
132
-
136
+
133
137
  # this assumes all years have 366 days (which only is true for leap years)
134
138
  # but since this is just for comparisons, this will be accurate
135
139
  #
136
140
  def _total_days
137
141
  self.to_d.yday + (@year * 366)
138
142
  end
139
-
143
+
140
144
  end
141
145
  end
@@ -1,13 +1,13 @@
1
1
  module Barometer
2
2
  #
3
3
  # A simple Time class
4
- #
4
+ #
5
5
  # A time class that represents the local time ...
6
6
  # it has no concept of time zone or date
7
7
  #
8
8
  class Data::LocalTime
9
9
  include Comparable
10
-
10
+
11
11
  attr_reader :hour, :min, :sec
12
12
 
13
13
  def initialize(h=0,m=0,s=0)
@@ -16,7 +16,7 @@ module Barometer
16
16
  self.sec = s
17
17
  self
18
18
  end
19
-
19
+
20
20
  def hour=(h)
21
21
  raise ArgumentError unless (h.is_a?(Fixnum) || h.nil?)
22
22
  hour_cap = 24
@@ -26,7 +26,7 @@ module Barometer
26
26
  @hour = h
27
27
  end
28
28
  end
29
-
29
+
30
30
  def min=(m)
31
31
  raise ArgumentError unless (m.is_a?(Fixnum) || m.nil?)
32
32
  minute_cap = 60
@@ -38,7 +38,7 @@ module Barometer
38
38
  @min = m
39
39
  end
40
40
  end
41
-
41
+
42
42
  def sec=(s)
43
43
  raise ArgumentError unless (s.is_a?(Fixnum) || s.nil?)
44
44
  second_cap = 60
@@ -50,7 +50,7 @@ module Barometer
50
50
  @sec = s
51
51
  end
52
52
  end
53
-
53
+
54
54
  def parse(string)
55
55
  if string.is_a?(Time) || string.is_a?(DateTime)
56
56
  @hour = string.hour
@@ -64,21 +64,21 @@ module Barometer
64
64
  end
65
65
  self
66
66
  end
67
-
67
+
68
68
  def self.parse(string)
69
69
  return string if string.is_a?(Data::LocalTime)
70
70
  local = Data::LocalTime.new
71
71
  local.parse(string)
72
72
  local
73
73
  end
74
-
74
+
75
75
  # convert to a Time class
76
76
  #
77
77
  def to_t
78
78
  date = Date.today
79
79
  Time.local(date.year,date.month,date.day,@hour,@min,@sec)
80
80
  end
81
-
81
+
82
82
  def total_seconds
83
83
  (@hour * 60 * 60) + (@min * 60) + @sec
84
84
  end
@@ -92,7 +92,7 @@ module Barometer
92
92
  raise ArgumentError unless the_other.is_a?(Data::LocalTime)
93
93
  total_seconds <=> the_other.total_seconds
94
94
  end
95
-
95
+
96
96
  def +(seconds)
97
97
  local_time = Data::LocalTime.new
98
98
  if seconds.is_a?(Fixnum) || seconds.is_a?(Float)
@@ -121,14 +121,14 @@ module Barometer
121
121
  raise ArgumentError unless the_other.is_a?(Data::LocalTime)
122
122
  (self.total_seconds - the_other.total_seconds).to_i.abs
123
123
  end
124
-
124
+
125
125
  def to_s(seconds=false)
126
126
  time = self.to_t
127
127
  format = (seconds ? "%I:%M:%S %p" : "%I:%M %p")
128
128
  time.strftime(format).downcase
129
129
  end
130
-
130
+
131
131
  def nil?; @hour == 0 && @min == 0 && @sec == 0; end
132
-
132
+
133
133
  end
134
134
  end