Given an input of float, int, Decimal, or number in str format, outputs a Decimal number rounded to n decimal places. This implements the typical round half up strategy where 0.5 rounds up.
This class is intended to generate numbers sequentially. A typical use case would be to define field mapping paths with next() and .last so that the Field Mapping paths are dynamically generated and an Include For Each isn’t necessary.
Be sure to keep() the instance of IndexGenerator in the relevant hook or an AttributeError exception will be thrown.
e.g:keep(custom_idx = data_utils.IndexGenerator())
Be aware that Glyue evaluates the Value Column on the Field Mapping table before the Field column which can result in unintended behavior. e.g.:
if custom_idx == 11;
Field Path: some.field.path[next(custom_idx)] → some.field.path[12]
Value Column: f”some_value{custom_idx.last}” → “some_value11“