Class: Integer

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

Overview

add some methods to classes for specialized output formats

Instance Method Summary collapse

Instance Method Details

#commasObject


4
5
6
7
8
9
10
# File 'lib/oat/support/classpatches.rb', line 4

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


12
13
14
15
16
17
18
# File 'lib/oat/support/classpatches.rb', line 12

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