forked from dblock/open-weather-ruby-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstation.rb
35 lines (29 loc) · 1.04 KB
/
station.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true
module OpenWeather
module Models
class Station < Model
property 'id', from: 'ID' # internal identifier for the station
property 'external_id' # external identifier for the station
property 'name' # name of the station
property 'latitude' # geographical coordinates of the location (latitude)
property 'longitude' # geographical coordinates of the location (longitude)
property 'altitude' # height of station above sea level
property 'created_at' # timestamp when station was created
property 'updated_at' # timestamp when station was updated
property 'rank' # rank of station
def register!
data = OpenWeather::Client.new.register_station(to_h)
update_attributes!(data)
self
end
def update!(attributes)
data = OpenWeather::Client.new.update_station(id, attributes)
update_attributes!(data)
self
end
def delete!
OpenWeather::Client.new.delete_station(id)
end
end
end
end