Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/zena/core_ext/float.rb

Instance Method Summary collapse

Instance Method Details

#fmt(pos = 2, sep = "'") ⇒ Object

Format a float with thousand separator and decimal positions.



3
4
5
6
# File 'lib/zena/core_ext/float.rb', line 3

def fmt(pos=2,sep="'")
  i = self.to_i.to_s.reverse
  i.gsub(/(\d\d\d)(?=\d)(?!\d*\.)/,'\1'+sep).reverse
end