parse static method

LexoDecimal parse(
  1. String str,
  2. LexoNumeralSystem system
)

Implementation

static LexoDecimal parse(String str, LexoNumeralSystem system) {
  final partialIndex = str.indexOf(system.getRadixPointChar());
  if (!identical(str.lastIndexOf(system.getRadixPointChar()), partialIndex)) {
    throw AssertionError('More than one ' + system.getRadixPointChar());
  }
  if (partialIndex < 0) {
    return LexoDecimal.make(LexoInteger.parse(str, system), 0);
  }
  final intStr =
      str.substring(0, partialIndex) + str.substring(partialIndex + 1);
  return LexoDecimal.make(
      LexoInteger.parse(intStr, system), str.length - 1 - partialIndex);
}