Class: Csv2Psql::Analyzers::Decimal
- Inherits:
-
BaseAnalyzer
- Object
- BaseAnalyzer
- Csv2Psql::Analyzers::Decimal
- Defined in:
- lib/csv2psql/analyzer/types/decimal.rb
Overview
Decimal value matcher
Constant Summary collapse
- TYPE =
:decimal- CLASS =
:numeric- WEIGHT =
3- RE =
Regexp.new(/^[-+]?[0-9]*[.,]?[0-9]+([eE][-+]?[0-9]+)?$/)
Class Method Summary collapse
Methods inherited from BaseAnalyzer
#analyze, #convert, #numeric?, numeric?, #sql_class, sql_class, sql_class?, #sql_class?, sql_type, #sql_type, sql_type?, #sql_type?, weight, #weight
Class Method Details
.analyze(val) ⇒ Object
15 16 17 18 19 |
# File 'lib/csv2psql/analyzer/types/decimal.rb', line 15 def analyze(val) return true if val.is_a?(Float) res = val && RE.match(val) !res.nil? end |
.convert(val) ⇒ Object
21 22 23 |
# File 'lib/csv2psql/analyzer/types/decimal.rb', line 21 def convert(val) val.to_f end |