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

Super-class for number printing directives, namely ~D (Decimal, ~B (Binary), ~O (Octal), and ~X (Hexadecimal). The only difference between these directives is the output radix, which defaults to ten (10), which is decimal.

Methods

execute   new  

Public Class methods

Create a Number directive, using the given output radix radix.

Public Instance methods

Output the given argument using its integral representation. The argument must respond to the :to_int message, or else it isn’t considered an integer. This is the normal way in which Ruby operates. The full form is

  ~mincol,padchar,commachar,commainterval:@[DBOX]

with the following interpretations

mincol (0)
minimum number of columns to output,
padchar (?\s)
character to pad with,
commachar (,)
character to use for number grouping (see : below),
commainterval (3)
how often to output commachar above,
:
the number is output, with numbers grouped into commainterval sized groups of numbers, using commachar as separator,
@
numbers are always output with sign prepended.

An ArgumentError is raised if the argument does not respond to the to_int message.

[Validate]