Class: DrivingPhysics::Car::Controls

Inherits:
Object
  • Object
show all
Defined in:
lib/driving_physics/car.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeControls

Returns a new instance of Controls.



141
142
143
144
145
# File 'lib/driving_physics/car.rb', line 141

def initialize
  @drive_pedal = 0.0     # up to 1.0
  @brake_pedal = 0.0     # up to 1.0
  @steering_wheel = 0.0  # -1.0 to 1.0
end

Instance Attribute Details

#brake_pedalObject

Returns the value of attribute brake_pedal.



139
140
141
# File 'lib/driving_physics/car.rb', line 139

def brake_pedal
  @brake_pedal
end

#drive_pedalObject

Returns the value of attribute drive_pedal.



139
140
141
# File 'lib/driving_physics/car.rb', line 139

def drive_pedal
  @drive_pedal
end

#steering_wheelObject

Returns the value of attribute steering_wheel.



139
140
141
# File 'lib/driving_physics/car.rb', line 139

def steering_wheel
  @steering_wheel
end

Instance Method Details

#to_sObject



159
160
161
162
163
164
# File 'lib/driving_physics/car.rb', line 159

def to_s
  [format("Throttle: %d%%", @drive_pedal * 100),
   format("Brake: %d%%", @brake_pedal * 100),
   format("Steering: %d%%", @steering_wheel * 100),
  ].join(" | ")
end