module FriendlyNumbers

Constants

VERSION

Public Instance Methods

number_to_currency(value, options = {}) click to toggle source

Convert a Number to a currency-formatted String

Options:

precision

number of decimal places

unit

symbol to prefix value

separator

symbol to separate thousands

# File lib/friendly_numbers.rb, line 16
def number_to_currency(value, options = {})
  NumberToCurrency.convert(value, options)
end
number_to_human_size(bytes, options = {}) click to toggle source

Convert a Number to a human-readable size of data

Options:

precision

number of decimal places

scales

Array of abbreviations in order

# File lib/friendly_numbers.rb, line 25
def number_to_human_size(bytes, options = {})
  NumberToHumanSize.convert(bytes, options)
end
number_to_percentage(value, options = {}) click to toggle source

Convert a Number to a percentage

Options:

precision

number of decimal places

# File lib/friendly_numbers.rb, line 33
def number_to_percentage(value, options = {})
  NumberToPercentage.convert(value, options)
end
seconds_to_time(seconds, options = {}) click to toggle source

Convert Seconds to an elapsed time

Options:

format

a callable object that receives hours, minutes, seconds as arguments

# File lib/friendly_numbers.rb, line 42
def seconds_to_time(seconds, options = {})
  SecondsToTime.convert(seconds, options)
end