Class: TeslaAPI::DriveState

Inherits:
Data
  • Object
show all
Defined in:
lib/tesla-api/drive_state.rb

Overview

Data defining the driving state of the the vehicle

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

#inspect, #ivar_from_data, #method_missing, #respond_to_missing?

Constructor Details

#initialize(data) ⇒ DriveState

initialize



28
29
30
31
32
33
34
35
# File 'lib/tesla-api/drive_state.rb', line 28

def initialize(data)
  ivar_from_data("shift_state", "shift_state", data)
  ivar_from_data("speed",       "speed",       data)
  ivar_from_data("latitude",    "latitude",    data)
  ivar_from_data("longitude",   "longitude",   data)
  ivar_from_data("heading",     "heading",     data)
  @gps_timestamp = Time.at(data["gps_as_of"])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TeslaAPI::Data

Instance Attribute Details

#gps_timestampObject (readonly)

Time when GPS data was recorded



5
6
7
# File 'lib/tesla-api/drive_state.rb', line 5

def gps_timestamp
  @gps_timestamp
end

Instance Method Details

#headingInteger

Returns Compass heading (0 to 360) degrees.

Returns:

  • (Integer)

    Compass heading (0 to 360) degrees



# File 'lib/tesla-api/drive_state.rb', line 23

#latitudeFloat

Returns Lattitude of vehicle.

Returns:

  • (Float)

    Lattitude of vehicle



# File 'lib/tesla-api/drive_state.rb', line 15

#longitudeFloat

Returns Longitude of vehicle.

Returns:

  • (Float)

    Longitude of vehicle



# File 'lib/tesla-api/drive_state.rb', line 19

#shift_stateObject

Unknown



# File 'lib/tesla-api/drive_state.rb', line 7

#speedObject

Vehicle speed (units?)



# File 'lib/tesla-api/drive_state.rb', line 11