Class: AxTrack::Tracker
- Defined in:
- lib/ax_track/objects/tracker.rb
Defined Under Namespace
Classes: GPSPosition
Instance Method Summary collapse
-
#initialize(json_response) ⇒ Tracker
constructor
A new instance of Tracker.
Methods inherited from Object
Constructor Details
#initialize(json_response) ⇒ Tracker
Returns a new instance of Tracker.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ax_track/objects/tracker.rb', line 4 def initialize(json_response) @id = json_response['id'] @url = json_response['url'] @active = json_response['active'] @model = json_response['model'] @axtrack_asset_id = json_response['asset'] @name = json_response.dig('asset_details', 'name') @last_message_timestamp = DateTime.parse(json_response['last_message_timestamp'], false) if json_response['last_message_timestamp'] @url = json_response['url'] @last_gps_position = GPSPosition.new(json_response['last_gps_measurement'] || json_response['asset_details']) @battery = json_response.dig('asset_details', 'sensor_data', 'battery', 'value') sensor_data = json_response.dig('asset_details', 'sensor_data') sensor_data.delete('battery') @sensor_data = sensor_data create_getters end |