Class: AxTrack::Tracker
- Inherits:
-
Object
- Object
- Object
- AxTrack::Tracker
show all
- Defined in:
- lib/ax_track/objects/tracker.rb,
lib/ax_track/objects/tracker/gps_position.rb
Defined Under Namespace
Classes: GPSPosition
Instance Method Summary
collapse
Methods inherited from Object
#create_getters, #initialize
Instance Method Details
#asset_details ⇒ Object
4
5
6
7
|
# File 'lib/ax_track/objects/tracker.rb', line 4
def asset_details
@asset_details = Asset.new @asset_details unless @asset_details.is_a? Asset
@asset_details
end
|
9
10
11
|
# File 'lib/ax_track/objects/tracker.rb', line 9
def asset_id
asset_details.id
end
|
#available_sensor_data ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/ax_track/objects/tracker.rb', line 38
def available_sensor_data
sensor_data_temp = self.sensor_data.keys
sensor_data_temp = sensor_data_temp.unshift('gps') if self.last_gps_position&.respond_to? :timestamp
sensor_data_temp
end
|
26
27
28
|
# File 'lib/ax_track/objects/tracker.rb', line 26
def battery
asset_details&.sensor_data.dig('battery', 'value')
end
|
#last_gps_position ⇒ Object
21
22
23
24
|
# File 'lib/ax_track/objects/tracker.rb', line 21
def last_gps_position
GPSPosition.new(@last_gps_measurement) unless @last_gps_measurement.nil?
end
|
#last_message_timestamp ⇒ Object
17
18
19
|
# File 'lib/ax_track/objects/tracker.rb', line 17
def last_message_timestamp
DateTime.parse(@last_message_timestamp, false) if @last_message_timestamp
end
|
13
14
15
|
# File 'lib/ax_track/objects/tracker.rb', line 13
def name
@name ||= asset_details.name
end
|
#sensor_data ⇒ Object
30
31
32
|
# File 'lib/ax_track/objects/tracker.rb', line 30
def sensor_data
asset_details.sensor_data
end
|
#website_url ⇒ Object
34
35
36
|
# File 'lib/ax_track/objects/tracker.rb', line 34
def website_url
"#{AxTrack.base_url_user}#{@id}"
end
|