Class: TeslaAPI::VehicleState
- Defined in:
- lib/tesla-api/vehicle_state.rb
Overview
Defines the current vehicle state
Instance Method Summary collapse
-
#dark_rims? ⇒ Boolean
If configured with dark colored rims.
-
#driver_front_door_open? ⇒ Boolean
If the driver’s side front door is open.
-
#driver_rear_door_open? ⇒ Boolean
If the driver’s side rear door is open.
-
#firmware_version ⇒ String
Current firmware version.
-
#front_trunk_open? ⇒ Boolean
If the front trunk (frunk) is open.
-
#initialize(data) ⇒ Boolean
constructor
If a performance configured vehicle.
-
#locked? ⇒ Boolean
If the doors are locked.
-
#nineteen_inch_wheels? ⇒ Boolean
If configured with nineteen inch wheels.
-
#panoramic? ⇒ Boolean
Configured with a panoramic roof.
-
#passenger_front_door_open? ⇒ Boolean
If the passenger’s side front door is open.
-
#passenger_rear_door_open ⇒ Boolean
If the passenger’s side rear door is open.
-
#perf? ⇒ Boolean
If a performance configured vehicle.
-
#spoiler? ⇒ Boolean
If configured with a spoiler.
-
#sun_roof_installed? ⇒ Boolean
If the vehicle is configured with the panoramic sun roof.
-
#sun_roof_percent_open ⇒ Integer
Percentage the sun roof is open.
-
#sun_roof_state ⇒ String
Potential values: unknown, moving.
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.
|
# File 'lib/tesla-api/vehicle_state.rb', line 49
|
#driver_front_door_open? ⇒ Boolean
Returns 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.
|
# File 'lib/tesla-api/vehicle_state.rb', line 25
|
#firmware_version ⇒ String
Returns Current firmware version.
|
# File 'lib/tesla-api/vehicle_state.rb', line 4
|
#front_trunk_open? ⇒ Boolean
Returns if the front trunk (frunk) is open.
|
# File 'lib/tesla-api/vehicle_state.rb', line 37
|
#locked? ⇒ Boolean
Returns 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.
|
# File 'lib/tesla-api/vehicle_state.rb', line 57
|
#panoramic? ⇒ Boolean
Returns 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.
|
# File 'lib/tesla-api/vehicle_state.rb', line 29
|
#passenger_rear_door_open ⇒ Boolean
Returns 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.
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.
|
# File 'lib/tesla-api/vehicle_state.rb', line 53
|
#sun_roof_installed? ⇒ Boolean
Returns if the vehicle is configured with the panoramic sun roof.
|
# File 'lib/tesla-api/vehicle_state.rb', line 8
|
#sun_roof_percent_open ⇒ Integer
Returns Percentage the sun roof is open.
|
# File 'lib/tesla-api/vehicle_state.rb', line 17
|
#sun_roof_state ⇒ String
Potential values: unknown, moving
|
# File 'lib/tesla-api/vehicle_state.rb', line 12
|