Class: DrivingPhysics::Car::Controls
- Inherits:
-
Object
- Object
- DrivingPhysics::Car::Controls
- Defined in:
- lib/driving_physics/car.rb
Instance Attribute Summary collapse
-
#brake_pedal ⇒ Object
Returns the value of attribute brake_pedal.
-
#drive_pedal ⇒ Object
Returns the value of attribute drive_pedal.
-
#steering_wheel ⇒ Object
Returns the value of attribute steering_wheel.
Instance Method Summary collapse
-
#initialize ⇒ Controls
constructor
A new instance of Controls.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Controls
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_pedal ⇒ Object
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_pedal ⇒ Object
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_wheel ⇒ Object
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_s ⇒ Object
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 |