toStringAsGlyph method

String toStringAsGlyph()

If possible, this method converts this MixedFraction instance into an unicode glyph string. For example:

MixedFraction(
  whole: 3,
  numerator: 1,
  denominator: 7,
).toStringAsGlyph() // "⅐"

If the conversion is not possible, a FractionException object is thrown.

Implementation

String toStringAsGlyph() {
  final glyph = Fraction(numerator, denominator).toStringAsGlyph();

  if (whole == 0) {
    return glyph;
  } else {
    return '$whole $glyph';
  }
}