Class: Numeric

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

Instance Method Summary collapse

Instance Method Details

#commaizeObject



677
678
679
# File 'lib/kiss/ext/core.rb', line 677

def commaize
  to_s.commaize
end

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



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

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

#to_dollarsObject



685
686
687
# File 'lib/kiss/ext/core.rb', line 685

def to_dollars
  commaize
end

#to_dollars_centsObject Also known as: format_currency



689
690
691
# File 'lib/kiss/ext/core.rb', line 689

def to_dollars_cents
  to_places(2).commaize
end

#to_places(num_places) ⇒ Object



681
682
683
# File 'lib/kiss/ext/core.rb', line 681

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