Module: Bizsh::Formatting
- Defined in:
- lib/bizsh.rb
Overview
String formatting for better ouput.
Constant Summary collapse
- DEFAULT_DECIMAL_PLACES =
Default the number of decimal places we show in strings.
2- FORMATTERS =
Format a number into a percentage.
{ percent: -> (value, *args) do value = value * 100 value = FORMATTERS[:decimal].call(value, *args) [value, '%'].join end, decimal: -> (value, places: DEFAULT_DECIMAL_PLACES) do "%.#{places}f" % value.to_f end }