Skip to content

Instantly share code, notes, and snippets.

@timurbakibayev
Created December 5, 2021 10:41
Show Gist options
  • Save timurbakibayev/e7062e125063763c1bcaf7ffef993f1f to your computer and use it in GitHub Desktop.
Save timurbakibayev/e7062e125063763c1bcaf7ffef993f1f to your computer and use it in GitHub Desktop.
from dataclasses import dataclass
from gasoline.gasoline import GasPortion
from gaspump.gaspump import GasPump
@dataclass
class Pedal:
connected_gas_pump: GasPump
def press(
self,
how_hard: float,
seconds: float,
) -> GasPortion:
if seconds < 0:
raise ValueError("No negative time period allowed")
how_hard = max(0, how_hard)
how_hard = min(1, how_hard)
return self.connected_gas_pump.apply(
voltage=12*how_hard,
seconds=seconds,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment