Module: Latias::String

Defined in:
lib/latias-string-commas.rb

Instance Method Summary collapse

Instance Method Details

#add_commas(m_str) ⇒ Object



3
4
5
6
7
# File 'lib/latias-string-commas.rb', line 3

def add_commas(m_str)
  m_str.to_s.reverse.scan(/\d{3}|.+/).join(',').reverse
rescue StandardError # optionally: `rescue Exception => ex`
  m_str
end