Class: CSVImportable::TypeParser::BooleanTypeParser

Inherits:
CSVImportable::TypeParser show all
Defined in:
lib/csv_importable/type_parser/boolean_type_parser.rb

Instance Attribute Summary

Attributes inherited from CSVImportable::TypeParser

#key, #required, #row, #value

Instance Method Summary collapse

Methods inherited from CSVImportable::TypeParser

#initialize, #parse

Constructor Details

This class inherits a constructor from CSVImportable::TypeParser

Instance Method Details

#error_messageObject



9
10
11
# File 'lib/csv_importable/type_parser/boolean_type_parser.rb', line 9

def error_message
  "Invalid boolean for column: #{key}"
end

#parse_valObject



3
4
5
6
7
# File 'lib/csv_importable/type_parser/boolean_type_parser.rb', line 3

def parse_val
  val = true if ["yes", "y", true, "true"].include?(value.downcase)
  val = false if ["no", "n", false, "false"].include?(value.downcase)
  val
end