Sha256: 8134b44232618c687b50917f662e1ef09b41ae750df0b52ae2b1ccb072dff77d

Contents?: true

Size: 691 Bytes

Versions: 8

Compression:

Stored size: 691 Bytes

Contents

class Numeric
  def to_currency(pre_symbol='$', thousands=',', decimal='.', post_symbol=nil) #:nodoc:
    "#{pre_symbol}#{("%.2f" % self ).gsub(/(\d)(?=(?:\d{3})+(?:$|\.))/,"\\1#{thousands}")}#{post_symbol}"
  end

  def microseconds() Float(self  * (10 ** -6)) end
  def milliseconds() Float(self  * (10 ** -3)) end
  def seconds() self end
  def minutes() 60 * seconds end
  def hours() 60 * minutes end
  def days() 24 * hours end
  def weeks() 7 * days end
  def months() 30 * days end
  def years() 365 * days end
  def decades() 10 * years end
  
  %w{ microseconds milliseconds seconds minutes hours days weeks months years decades
  }.each{ |m| mm = m.chop; alias_method mm, m }

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
merb-0.0.8 lib/merb/core_ext/merb_numeric.rb
merb-0.0.9 lib/merb/core_ext/merb_numeric.rb
merb-0.3.1 lib/merb/core_ext/merb_numeric.rb
merb-0.1.0 lib/merb/core_ext/merb_numeric.rb
merb-0.3.0 lib/merb/core_ext/merb_numeric.rb
merb-0.3.3 lib/merb/core_ext/merb_numeric.rb
merb-0.3.4 lib/merb/core_ext/merb_numeric.rb
merb-0.2.0 lib/merb/core_ext/merb_numeric.rb