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?
  /^(\+|-)?[0-9]+((\.|,)[0-9]+)?$/.match?(self)
end

#to_number(_options = {}) ⇒ Object



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

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

  nil
end