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



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



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


#driver_front_door_open?Boolean



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


#driver_rear_door_open?Boolean



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


#firmware_versionString



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


#front_trunk_open?Boolean



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


#locked?Boolean



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


#nineteen_inch_wheels?Boolean



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


#panoramic?Boolean



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


#passenger_front_door_open?Boolean



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


#passenger_rear_door_openBoolean



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


#perf?Boolean



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



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


#sun_roof_installed?Boolean



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


#sun_roof_percent_openInteger



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


#sun_roof_stateString

Potential values: unknown, moving



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