Class: Numeric

Inherits:
Object show all
Defined in:
lib/kiss/ext/core.rb

Instance Method Summary collapse

Instance Method Details

#commaizeObject



697
698
699
# File 'lib/kiss/ext/core.rb', line 697

def commaize
  to_s.commaize
end

#quantity(unit) ⇒ Object Also known as: of



714
715
716
# File 'lib/kiss/ext/core.rb', line 714

def quantity(unit)
  "#{self.commaize} #{ self != 1 ? unit.pluralize : unit }"
end

#to_dollarsObject



705
706
707
# File 'lib/kiss/ext/core.rb', line 705

def to_dollars
  commaize
end

#to_dollars_centsObject Also known as: format_currency



709
710
711
# File 'lib/kiss/ext/core.rb', line 709

def to_dollars_cents
  to_places(2).commaize
end

#to_places(num_places) ⇒ Object



701
702
703
# File 'lib/kiss/ext/core.rb', line 701

def to_places(num_places)
  sprintf("%0.#{num_places}f", self)
end