Module: Brcobranca::Currency::String

Defined in:
lib/brcobranca/currency.rb

Overview

Instance Method Summary collapse

Instance Method Details

#numeric?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/brcobranca/currency.rb', line 15

def numeric?
  self =~ /^(\+|-)?[0-9]+((\.|,)[0-9]+)?$/ ? true : false
end

#to_number(options = {}) ⇒ Object



10
11
12
13
# File 'lib/brcobranca/currency.rb', line 10

def to_number(options={})
  return self.gsub(/,/, '.').to_f if self.numeric?
  nil
end