Class: Fixnum

Inherits:
Object
  • Object
show all
Defined in:
lib/oa_templater.rb

Instance Method Summary collapse

Instance Method Details

#commasObject



54
55
56
57
58
59
60
# File 'lib/oa_templater.rb', line 54

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



62
63
64
65
66
67
68
# File 'lib/oa_templater.rb', line 62

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