Class: OrbDef::WeatherStation
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- OrbDef::WeatherStation
- Defined in:
- app/models/orb_def/weather_station.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_or_create(reading_json) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/orb_def/weather_station.rb', line 14 def find_or_create(reading_json) identifier = "#{reading_json['name']}:AUS" weather_station = WeatherStation.find_by(identifier: identifier) return weather_station if weather_station.present? WeatherStation.create( identifier: identifier, name: reading_json['name'], latitude: reading_json['coord']['lat'], longitude: reading_json['coord']['lon'] ) end |
Instance Method Details
#latest_weather_reading ⇒ Object
29 30 31 |
# File 'app/models/orb_def/weather_station.rb', line 29 def latest_weather_reading self.weather_readings.last end |