apply method

  1. @override
String apply()

Apply the list of carvings currently added to the carvable object.

This method will apply all the carving zones into a result. Each carving can be called and passed in their respective data type, a result will mostly come from the chaining of these carvings, when having the input and result with the same data types.

Implementation

@override
String apply() {
  int offset = this.offset;
  return carvings.fold(input, (value, carving) {
    final String result = carving is PositionalCarving<String, String>
        ? carving.apply(value, offset: offset)
        : carving.apply(value);

    offset += value.length - result.length;
    return result;
  });
}