Class: HistoricalObservation

Inherits:
Weatherzone::Resource show all
Includes:
Weatherzone::Helpers::Units
Defined in:
lib/weatherzone/resources/historical_observation.rb

Constant Summary collapse

WIND_SPEED_RANGE =
{
  (0..19) => "calm",                                                                                       
  (20..30) => "moderate",
  (31..39) => "fresh",
  (40..61) => "strong",
  (62..87) => "gale",
  (88..1.0/0) => "storm"
}

Instance Method Summary collapse

Methods included from Weatherzone::Helpers::Units

included

Methods inherited from Weatherzone::Resource

has_attribute, has_elements, inherited, #settings

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/weatherzone/resources/historical_observation.rb', line 53

def eql?(other)
  self.obs_time_local == other.obs_time_local
end

#hashObject



49
50
51
# File 'lib/weatherzone/resources/historical_observation.rb', line 49

def hash
  obs_time_local.hash
end

#is_on_the_half_hour?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/weatherzone/resources/historical_observation.rb', line 33

def is_on_the_half_hour?
  obs_time_local.change(:min => 0) == obs_time_local || obs_time_local.change(:min => 30) == obs_time_local
end

#is_on_the_hour?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/weatherzone/resources/historical_observation.rb', line 37

def is_on_the_hour?
  obs_time_local.change(:min => 0) == obs_time_local
end

#obs_time_localObject



29
30
31
# File 'lib/weatherzone/resources/historical_observation.rb', line 29

def obs_time_local
  Time.parse(@obs_time_local)
end

#rainfall_mmObject



45
46
47
# File 'lib/weatherzone/resources/historical_observation.rb', line 45

def rainfall_mm
  @rainfall_mm || "0"
end

#wind_speedObject



41
42
43
# File 'lib/weatherzone/resources/historical_observation.rb', line 41

def wind_speed
  WIND_SPEED_RANGE.find_by_speed(wind_speed_kph)
end