Module: Brcobranca::Currency::String

Defined in:
lib/brcobranca/currency.rb

Overview

Instance Method Summary collapse

Instance Method Details

#numeric?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'lib/brcobranca/currency.rb', line 19

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

#to_number(_options = {}) ⇒ Object


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

def to_number(_options = {})
  return tr(',', '.').to_f if numeric?
  nil
end