Parent

Namespace

Files

Numeric

Public Instance Methods

minutes_to_hours() click to toggle source
 Converts a +numeric+ value representing minutes into a string representing an hour value

 ==== Parameters
 number<Numeric>:: Numeric value representing minutes to convert in hours

 ==== Returns
 String:: a string representing the numeric value converted in hours

 ==== Examples
 315.minutes_to_hours => "05:15"

 @public
     # File lib/merb-helpers/core_ext/numeric.rb, line 384
384:   def minutes_to_hours
385:     Transformer.minutes_to_hours(self)
386:   end
to_currency(format_name = nil, options = {}) click to toggle source
 Formats into a currency string (e.g., $13.65). You can specify a format to use 
 and even overwrite some of the format options.

 ==== Parameters
 format_name<Symbol>:: name of the format to use
 options<Hash>:: options which will overwrite the used format

 ==== Returns
 String:: a string representing the number converted in currency

 ==== Options
 :precision - Sets the level of precision 
 :unit - Sets the denomination of the currency 
 :format - Sets the format of the output string (defaults to "%u%n"). The field types are:

 %u The currency unit
 %n The number

 ==== Examples
 1234567890.506.to_currency(:US)                   # => "$1,234,567,890.51"
 1234567890.506.to_currency(:US, :precision => 1)  # => "$1,234,567,890.5"
 1234567890.516.to_currency(:FR)                   # =>"1 234 567 890,52€"
 1234567890.516.to_currency(:US, :unit => "€")     # =>"€1,234,567,890.52"
 1234567890.506.to_currency(:US, :precision => 3, :unit => "€") # => "€1,234,567,890.506"
 1234567890.506.to_currency(:AU, :unit => "$AUD", :format => '%n %u') # => "1,234,567,890.51 $AUD"

 @public
     # File lib/merb-helpers/core_ext/numeric.rb, line 353
353:   def to_currency(format_name = nil, options = {})
354:     Transformer.to_currency(self, format_name, options)
355:   end
two_digits() click to toggle source
 Formats a +number+ into a two digit string. Basically it prepends an integer to a 2 digits string.

 ==== Returns
 String:: a string representing the number converted into a 2 digits string.

 ==== Examples
 (5-3).two_digits # => "02"

 @public
     # File lib/merb-helpers/core_ext/numeric.rb, line 367
367:   def two_digits
368:     Transformer.two_digits(self)
369:   end
with_delimiter(format_name = nil, options = {}) click to toggle source
 Formats with with grouped thousands using +delimiter+ (e.g., 12,324). You can
 pass another format to format the number differently.

 ==== Parameters
 format_name<Symbol>:: name of the format to use
 options<Hash>:: options which will overwrite the used format

 ==== Returns
 String:: a string representing the delimited number

 ==== Options
 :delimiter - Overwrites the thousands delimiter.
 :separator - Overwrites the separator between the units.

 ==== Examples
 12345678.with_delimiter      # => 12,345,678
 12345678.05.with_delimiter   # => 12,345,678.05
 12345678.with_delimiter(:FR) # => 12.345.678
 12345678.with_delimiter(:US) # => 12,345,678

 @public
     # File lib/merb-helpers/core_ext/numeric.rb, line 295
295:   def with_delimiter(format_name = nil, options = {})
296:     Transformer.with_delimiter(self, format_name, options)
297:   end
with_precision(format_name = nil, options = {}) click to toggle source
 Formats with a level of <tt>:precision</tt> (e.g., 112.32 has a precision of 2).
 You can pass another format to use and even overwrite the format's options.

 ==== Parameters
 format_name<Symbol>:: name of the format to use
 options<Hash>:: options which will overwrite the used format

 ==== Returns
 String:: a string representing the delimited number

 ==== Options
 :precision - Overwrites the level of precision
 :separator - Overwrites the separator between the units
 :delimiter - Overwrites the thousands delimiter

 ==== Examples
 111.2345.with_precision                       # => 111.235
 111.2345.with_precision(:UK, :precision => 1) # => "111.2"
 1234.567.with_precision(:US, :precision => 1, :separator => ',', :delimiter => '-') # => "1-234,6"

 @public
     # File lib/merb-helpers/core_ext/numeric.rb, line 322
322:   def with_precision(format_name = nil, options = {})
323:     Transformer.with_precision(self, format_name, options)
324:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.