Class Index | File Index

Classes


Class UnitFmt

Create a new unit formatter instance. The unit formatter is immutable once it is created, but can format as many different strings with different values as needed with the same options. Create different unit formatter instances for different purposes and then keep them cached for use later if you have more than one unit string to format.

The options may contain any of the following properties:

Here is an example of how you might use the unit formatter to format a string with the correct units.


Defined in: ilib-full-dyn.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
UnitFmt(options)
Method Summary
Method Attributes Method Name and Description
 
format(measurement)
Format a particular unit instance according to the settings of this formatter object.
 
Return the locale used with this formatter instance.
 
Return the measurement system that is used for this formatter.
 
Return whether or not this formatter will auto-scale the units while formatting.
 
Return the template string that is used to format date/times for this formatter instance.
 
Convert this formatter to a string representation by returning the format template.
Class Detail
UnitFmt(options)
Parameters:
{Object} options
options governing the way this date formatter instance works
Method Detail
{string} format(measurement)
Format a particular unit instance according to the settings of this formatter object.
Parameters:
{Measurement} measurement
measurement to format
Returns:
{string} the formatted version of the given date instance

{Locale} getLocale()
Return the locale used with this formatter instance.
Returns:
{Locale} the Locale instance for this formatter

{string} getMeasurementSystem()
Return the measurement system that is used for this formatter.
Returns:
{string} the measurement system used in this formatter

{boolean} getScale()
Return whether or not this formatter will auto-scale the units while formatting.
Returns:
{boolean} true if auto-scaling is turned on

{string} getTemplate()
Return the template string that is used to format date/times for this formatter instance. This will work, even when the template property is not explicitly given in the options to the constructor. Without the template option, the constructor will build the appropriate template according to the options and use that template in the format method.
Returns:
{string} the format template for this formatter

{string} toString()
Convert this formatter to a string representation by returning the format template. This method delegates to getTemplate.
Returns:
{string} the format template

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Feb 02 2016 15:53:55 GMT-0800 (PST)