Class Lisp::Format::Directives::Radix
In: lib/facet/lisp-format.rb
Parent: Directive

Represents the ~R (Radix) directive. This outputs numbers in a given radix, or using alternative forms, such as Roman numerals or cardinal/ordinal English numbers.

Methods

Public Instance methods

Output the given argument using one of a variety of methods. Either the argument is output using a specific radix, using cardinal or ordinal English numbers, or Roman numerals. The full form is

  ~radix,mincol,padchar,commachar,commainterval:@R

with the same interpretation as for ~D (Decimal / Number), but using the given radix instead. An ArgumentError is raised if the argument is not an integer, or, in the case of Roman numerals, if the argument is not a Fixnum value.

If none of the parameters are given the output instead depends on the combination of modifiers:

no modifiers
the number is output as a cardinal English number,
:
the number is output as an ordinal English number,
@
the number is output as a Roman numeral,
:@
the number is output as an old Roman numeral.

An ArgumentError is raised if the argument is not an integer.

Private Instance methods

Convert the given number to a cardinal English number string.

Deal with hundreds for cardinals.

Convert the given number to an old Roman numeral.

Convert the given number to an ordinal English number string.

Convert the given number to a Roman numeral.

Helper method for roman numerals.

[Validate]