Class: WeatherSage::Weather::Station
- Inherits:
-
BaseObject
- Object
- BaseObject
- WeatherSage::Weather::Station
- Defined in:
- lib/weather-sage/weather/station.rb
Overview
Thin wrapper around weather station.
Instance Attribute Summary collapse
-
#elevation ⇒ Object
readonly
Returns the value of attribute elevation.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#time_zone ⇒ Object
readonly
Returns the value of attribute time_zone.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Attributes inherited from BaseObject
Class Method Summary collapse
-
.from_json(ctx, row) ⇒ Object
Create a new Station from the given Context
ctxand the JSON datarow.
Instance Method Summary collapse
-
#initialize(ctx, id, name, x, y, elevation, time_zone) ⇒ Station
constructor
Create a new station instance.
-
#latest_observations ⇒ Object
Return a hash of the latest observations from this station.
Constructor Details
#initialize(ctx, id, name, x, y, elevation, time_zone) ⇒ Station
Create a new station instance.
26 27 28 29 30 31 32 33 34 |
# File 'lib/weather-sage/weather/station.rb', line 26 def initialize(ctx, id, name, x, y, elevation, time_zone) @ctx = ctx @id = id @name = name @x = x @y = y @elevation = elevation @time_zone = time_zone end |
Instance Attribute Details
#elevation ⇒ Object (readonly)
Returns the value of attribute elevation.
5 6 7 |
# File 'lib/weather-sage/weather/station.rb', line 5 def elevation @elevation end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/weather-sage/weather/station.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/weather-sage/weather/station.rb', line 5 def name @name end |
#time_zone ⇒ Object (readonly)
Returns the value of attribute time_zone.
5 6 7 |
# File 'lib/weather-sage/weather/station.rb', line 5 def time_zone @time_zone end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
5 6 7 |
# File 'lib/weather-sage/weather/station.rb', line 5 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
5 6 7 |
# File 'lib/weather-sage/weather/station.rb', line 5 def y @y end |
Class Method Details
.from_json(ctx, row) ⇒ Object
Create a new Station from the given Context ctx and the JSON data row.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/weather-sage/weather/station.rb', line 11 def self.from_json(ctx, row) new( ctx, row['properties']['stationIdentifier'], row['properties']['name'], row['geometry']['coordinates'][0], row['geometry']['coordinates'][1], row['properties']['elevation']['value'], row['properties']['timeZone'] ) end |
Instance Method Details
#latest_observations ⇒ Object
Return a hash of the latest observations from this station.
39 40 41 42 |
# File 'lib/weather-sage/weather/station.rb', line 39 def latest_observations path = 'stations/%s/observations/latest' % [@id] get(path)['properties'] end |