Class: Numeric

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

Instance Method Summary collapse

Instance Method Details

#commaizeObject



683
684
685
# File 'lib/kiss/ext/core.rb', line 683

def commaize
  to_s.commaize
end

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



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

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

#to_dollarsObject



691
692
693
# File 'lib/kiss/ext/core.rb', line 691

def to_dollars
  commaize
end

#to_dollars_centsObject Also known as: format_currency



695
696
697
# File 'lib/kiss/ext/core.rb', line 695

def to_dollars_cents
  to_places(2).commaize
end

#to_places(num_places) ⇒ Object



687
688
689
# File 'lib/kiss/ext/core.rb', line 687

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