Class: Location
Instance Attribute Summary collapse
Instance Method Summary
collapse
has_attribute, has_elements, inherited, #settings
Instance Attribute Details
override base ruby Object#type
36
37
38
|
# File 'lib/weatherzone/resources/location.rb', line 36
def type
@type
end
|
Instance Method Details
#<=>(other) ⇒ Object
99
100
101
|
# File 'lib/weatherzone/resources/location.rb', line 99
def <=>(other)
self.name <=> other.name
end
|
#current_conditions ⇒ Object
46
47
48
|
# File 'lib/weatherzone/resources/location.rb', line 46
def current_conditions
@current_conditions ||= conditions.first
end
|
#current_district_forecast ⇒ Object
50
51
52
|
# File 'lib/weatherzone/resources/location.rb', line 50
def current_district_forecast
@current_district_forecast ||= district_forecasts.first
end
|
#current_district_forecast_precis ⇒ Object
54
55
56
|
# File 'lib/weatherzone/resources/location.rb', line 54
def current_district_forecast_precis
current_district_forecast ? current_district_forecast.precis : "District forecast unavailable"
end
|
#current_forecast ⇒ Object
42
43
44
|
# File 'lib/weatherzone/resources/location.rb', line 42
def current_forecast
@current_forecast ||= forecasts.first
end
|
#current_marine_forecast ⇒ Object
74
75
76
|
# File 'lib/weatherzone/resources/location.rb', line 74
def current_marine_forecast
@marine_forecast ||= marine_forecasts.first
end
|
#current_state_forecast ⇒ Object
58
59
60
|
# File 'lib/weatherzone/resources/location.rb', line 58
def current_state_forecast
@current_state_forecast ||= state_forecasts.first
end
|
#current_state_forecast_precis ⇒ Object
62
63
64
|
# File 'lib/weatherzone/resources/location.rb', line 62
def current_state_forecast_precis
current_state_forecast ? current_state_forecast.precis : "State forecast unavailable"
end
|
#current_synoptic_chart ⇒ Object
66
67
68
|
# File 'lib/weatherzone/resources/location.rb', line 66
def current_synoptic_chart
synoptic_chart.first
end
|
#current_synoptic_chart_text ⇒ Object
70
71
72
|
# File 'lib/weatherzone/resources/location.rb', line 70
def current_synoptic_chart_text
current_synoptic_chart ? current_synoptic_chart.text : "Synoptic chart unavailable"
end
|
#historical_observations_shifted_to_nearest_half_hour ⇒ Object
78
79
80
81
82
83
84
85
|
# File 'lib/weatherzone/resources/location.rb', line 78
def historical_observations_shifted_to_nearest_half_hour
obs_to_shift = historical_observations.uniq.reverse
historical_observations.each do |ho|
break if ho.is_on_the_half_hour?
obs_to_shift.shift
end
obs_to_shift
end
|
#hourly_observations ⇒ Object
87
88
89
|
# File 'lib/weatherzone/resources/location.rb', line 87
def hourly_observations
historical_observations.uniq.reverse.select { |ho| ho.is_on_the_hour? }
end
|
38
39
40
|
# File 'lib/weatherzone/resources/location.rb', line 38
def id
code
end
|
91
92
93
|
# File 'lib/weatherzone/resources/location.rb', line 91
def position
"(#{self.lat}°S, #{self.long}°E, #{self.elevation}m AMSL)"
end
|
95
96
97
|
# File 'lib/weatherzone/resources/location.rb', line 95
def url_slug
self.name.parameterize
end
|