Class: TeslaAPI::VehicleState

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

Overview

Defines the current vehicle state

Instance Method Summary collapse

Methods inherited from Data

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

Constructor Details

#initialize(data) ⇒ Boolean

Returns if a performance configured vehicle.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/tesla-api/vehicle_state.rb', line 69

def initialize(data)
  ivar_from_data("firmware_version",          "car_version",           data)
  ivar_from_data("sun_roof_installed",        "sun_roof_installed",    data)
  ivar_from_data("sun_roof_state",            "sun_roof_state",        data)
  ivar_from_data("sun_roof_percent_open",     "sun_roof_percent_open", data)
  ivar_from_data("driver_front_door_open",    "df",                    data)
  ivar_from_data("driver_rear_door_open",     "dr",                    data)
  ivar_from_data("passenger_front_door_open", "pf",                    data)
  ivar_from_data("passenger_rear_door_open",  "pr",                    data)
  ivar_from_data("front_trunk_open",          "ft",                    data)
  ivar_from_data("rear_trunk_open",           "rt",                    data)
  ivar_from_data("locked",                    "locked",                data)
  ivar_from_data("dark_rims",                 "dark_rims",             data)
  ivar_from_data("spoiler",                   "has_spoiler",           data)

  @nineteen_inch_wheels      = data["wheel_type"] == "Base19"
  @panoramic                 = data["roof_color"] == "None"
  @perf                      = data["perf_config"] != "Base"
end

Dynamic Method Handling

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

Instance Method Details

#dark_rims?Boolean

Returns if configured with dark colored rims.

Returns:

  • (Boolean)

    if configured with dark colored rims



# File 'lib/tesla-api/vehicle_state.rb', line 49

#driver_front_door_open?Boolean

Returns if the driver’s side front door is open.

Returns:

  • (Boolean)

    if the driver’s side front door is open



# File 'lib/tesla-api/vehicle_state.rb', line 21

#driver_rear_door_open?Boolean

Returns if the driver’s side rear door is open.

Returns:

  • (Boolean)

    if the driver’s side rear door is open



# File 'lib/tesla-api/vehicle_state.rb', line 25

#firmware_versionString

Returns Current firmware version.

Returns:

  • (String)

    Current firmware version



# File 'lib/tesla-api/vehicle_state.rb', line 4

#front_trunk_open?Boolean

Returns if the front trunk (frunk) is open.

Returns:

  • (Boolean)

    if the front trunk (frunk) is open



# File 'lib/tesla-api/vehicle_state.rb', line 37

#locked?Boolean

Returns if the doors are locked.

Returns:

  • (Boolean)

    if the doors are locked



# File 'lib/tesla-api/vehicle_state.rb', line 45

#nineteen_inch_wheels?Boolean

Returns if configured with nineteen inch wheels.

Returns:

  • (Boolean)

    if configured with nineteen inch wheels



# File 'lib/tesla-api/vehicle_state.rb', line 57

#panoramic?Boolean

Returns configured with a panoramic roof.

Returns:

  • (Boolean)

    configured with a panoramic roof



# File 'lib/tesla-api/vehicle_state.rb', line 61

#passenger_front_door_open?Boolean

Returns if the passenger’s side front door is open.

Returns:

  • (Boolean)

    if the passenger’s side front door is open



# File 'lib/tesla-api/vehicle_state.rb', line 29

#passenger_rear_door_openBoolean

Returns if the passenger’s side rear door is open.

Returns:

  • (Boolean)

    if the passenger’s side rear door is open



# File 'lib/tesla-api/vehicle_state.rb', line 33

#perf?Boolean

Returns if a performance configured vehicle.

Returns:

  • (Boolean)

    if a performance configured vehicle



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/tesla-api/vehicle_state.rb', line 69

def initialize(data)
  ivar_from_data("firmware_version",          "car_version",           data)
  ivar_from_data("sun_roof_installed",        "sun_roof_installed",    data)
  ivar_from_data("sun_roof_state",            "sun_roof_state",        data)
  ivar_from_data("sun_roof_percent_open",     "sun_roof_percent_open", data)
  ivar_from_data("driver_front_door_open",    "df",                    data)
  ivar_from_data("driver_rear_door_open",     "dr",                    data)
  ivar_from_data("passenger_front_door_open", "pf",                    data)
  ivar_from_data("passenger_rear_door_open",  "pr",                    data)
  ivar_from_data("front_trunk_open",          "ft",                    data)
  ivar_from_data("rear_trunk_open",           "rt",                    data)
  ivar_from_data("locked",                    "locked",                data)
  ivar_from_data("dark_rims",                 "dark_rims",             data)
  ivar_from_data("spoiler",                   "has_spoiler",           data)

  @nineteen_inch_wheels      = data["wheel_type"] == "Base19"
  @panoramic                 = data["roof_color"] == "None"
  @perf                      = data["perf_config"] != "Base"
end

#spoiler?Boolean

Returns if configured with a spoiler.

Returns:

  • (Boolean)

    if configured with a spoiler



# File 'lib/tesla-api/vehicle_state.rb', line 53

#sun_roof_installed?Boolean

Returns if the vehicle is configured with the panoramic sun roof.

Returns:

  • (Boolean)

    if the vehicle is configured with the panoramic sun roof



# File 'lib/tesla-api/vehicle_state.rb', line 8

#sun_roof_percent_openInteger

Returns Percentage the sun roof is open.

Returns:

  • (Integer)

    Percentage the sun roof is open



# File 'lib/tesla-api/vehicle_state.rb', line 17

#sun_roof_stateString

Potential values: unknown, moving

Returns:

  • (String)

    Current state of the sun roof



# File 'lib/tesla-api/vehicle_state.rb', line 12