Class: String

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

Overview

Would be ideal if we could only add this functionality only if included

Instance Method Summary collapse

Instance Method Details

#old_to_iObject



20
# File 'lib/number_name_string.rb', line 20

alias_method :old_to_i, :to_i

#to_commaObject



22
23
24
# File 'lib/number_name_string.rb', line 22

def to_comma
  self.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
end

#to_iObject



26
27
28
29
30
# File 'lib/number_name_string.rb', line 26

def to_i
  # TODO: verify output may be a string and this is necessary
  result = NumberNameString[self]
  result.is_a?(String) ? result.old_to_i : result
end