Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/oat/support/classpatches.rb

Instance Method Summary collapse

Instance Method Details

#commasObject


22
23
24
25
26
27
28
# File 'lib/oat/support/classpatches.rb', line 22

def commas
  to_s =~ /([^\.]*)(\..*)?/
  int, dec = Regexp.last_match[1].reverse, Regexp.last_match[2] ? Regexp.last_match[2] : ''
  while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2,\3')
  end
  int.reverse + dec
end

#eurostyleObject


30
31
32
33
34
35
36
# File 'lib/oat/support/classpatches.rb', line 30

def eurostyle
  to_s =~ /([^\.]*)(\..*)?/
  int, dec = Regexp.last_match[1].reverse, Regexp.last_match[2] ? Regexp.last_match[2] : ''
  while int.gsub!(/( |\.|^)(\d{3})(\d)/, '\1\2 \3')
  end
  int.reverse + dec
end