21 lines
661 B
Python
21 lines
661 B
Python
from cyclinglib.speed import Speed
|
|
|
|
|
|
class GearRatio:
|
|
|
|
def __init__(self, front_teeth: int, rear_teeth: int):
|
|
self._gear_ratio: float = front_teeth / rear_teeth
|
|
|
|
def speed_at_cadence(self, cadence: int,
|
|
wheel_circumference_mm: int) -> Speed:
|
|
"""
|
|
Cadence is specified in revolutions per minute.
|
|
"""
|
|
revolutions_per_second = cadence / 60
|
|
wheel_circumference_m = wheel_circumference_mm / 1_000
|
|
return Speed(wheel_circumference_m * revolutions_per_second *
|
|
self._gear_ratio)
|
|
|
|
def __str__(self) -> str:
|
|
return f"Gear ratio: {self._gear_ratio}"
|