Class: Csv2Psql::Analyzers::Boolean
- Inherits:
-
BaseAnalyzer
- Object
- BaseAnalyzer
- Csv2Psql::Analyzers::Boolean
- Defined in:
- lib/csv2psql/analyzer/types/boolean.rb
Overview
Bolean value matcher
Constant Summary collapse
- TYPE =
:boolean- CLASS =
:special- WEIGHT =
5- TRUE_VALUES =
[ true, 't', 'true', 'y', 'yes', 'on', '1', ]
- FALSE_VALUES =
[ false, 'f', 'false', 'n', 'no', 'off', '0' ]
- BOOLEAN_VALUES =
TRUE_VALUES + FALSE_VALUES
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
34 35 36 37 |
# File 'lib/csv2psql/analyzer/types/boolean.rb', line 34 def analyze(val) return false if val.nil? || val.empty? BOOLEAN_VALUES.index(val) != nil end |
.convert(val) ⇒ Object
39 40 41 |
# File 'lib/csv2psql/analyzer/types/boolean.rb', line 39 def convert(val) val.downcase end |