Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/number_name_string.rb
Overview
Extends String class with to_comma and updated to_i
Instance Method Summary collapse
Instance Method Details
#add_commas ⇒ Object
32 33 34 |
# File 'lib/number_name_string.rb', line 32 def add_commas self.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse end |
#old_to_i ⇒ Object
26 |
# File 'lib/number_name_string.rb', line 26 alias_method :old_to_i, :to_i |
#to_comma ⇒ Object
28 29 30 |
# File 'lib/number_name_string.rb', line 28 def to_comma self.to_i.to_comma end |
#to_i ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/number_name_string.rb', line 36 def to_i if self =~ /^\d+$/ old_to_i else NumberNameString[self] end end |