recipe_grid.scaled_value_string
: Scaled Value Strings¶
A string type in which embedded numerical values can be re-scaled.
- class recipe_grid.scaled_value_string.ScaledValueString(string: str | int | float | Fraction | Sequence[str | int | float | Fraction] = '')¶
A string which contains some numerical values which may be re-scaled by a fixed factor.
This type is very specifically aimed at strings within recipes of the style “divide into 8 burgers about 10cm in diameter”. Here when the recipe is scaled up or down, the ‘8’ should be scaled but the ‘10’ should not. Here a
ScaledValueString
would be defined like so:>>> for_8_burgers = ScaledValueString( ... ["divide into ", 8, " burgers about 10cm in diameter"] ... )
This could be scaled up like so:
>>> for_16_burgers = for_8_burgers.scale(2) >>> for_16_burgers.render() 'divide into 16 burgers about 10cm in diameter'