Caplin Trader 4.8.0

Class: module:caplin/element/formatter/Fractional8thsFormatter

module:caplin/element/formatter/Fractional8thsFormatter

Constructor

new module:caplin/element/formatter/Fractional8thsFormatter()

Formats a decimal to a mixed fraction, rounded to the nearest eighth.

Fractional8thsFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to 1\u215B (one and one eighth, in unicode):

caplin.element.formatter.Fractional8thsFormatter.format(1.126, {})
Implements:

Methods

format(vValue, mAttributes) → {String}

Formats a decimal to a mixed fraction, rounded to the nearest eighth.
Parameters:
Name Type Description
vValue Variant the decimal number (String or Number type).
mAttributes Map the map of attributes.
Properties
Name Type Attributes Default Description
leadingZero boolean <optional>
false if true, mixed fractions with no integer part are shown with a leading zero.
1 String <optional>
\u215B the character to use for one eighth.
2 String <optional>
\u00BC the character to use for two eighths.
3 String <optional>
\u215C the character to use for three eighths.
4 String <optional>
\u00BD the character to use for four eighths.
5 String <optional>
\u215D the character to use for five eighths.
6 String <optional>
\u00BE the character to use for six eighths.
7 String <optional>
\u215E the character to use for seven eighths.
Returns:
the mixed fraction, in unicode.
Type
String