Class: FlatKit::FieldType::UnknownType

Inherits:
FlatKit::FieldType show all
Defined in:
lib/flat_kit/field_type/unknown_type.rb

Constant Summary collapse

REGEX =
%r{\A(na|n/a|unk|unknown)\Z}i

Constants inherited from FlatKit::FieldType

CoerceFailure

Class Method Summary collapse

Methods inherited from FlatKit::FieldType

best_guess, candidate_types, weight

Methods included from DescendantTracker

#children, #find_child, #find_children, #inherited

Class Method Details

.coerce(data) ⇒ Object



17
18
19
20
21
22
# File 'lib/flat_kit/field_type/unknown_type.rb', line 17

def self.coerce(data)
  return data if REGEX.match?(data)
  return CoerceFailure
rescue
  return CoerceFailure
end

.matches?(data) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/flat_kit/field_type/unknown_type.rb', line 11

def self.matches?(data)
  return false unless data.kind_of?(String)
  return true if data.length == 0
  return REGEX.match?(data)
end

.type_nameObject



7
8
9
# File 'lib/flat_kit/field_type/unknown_type.rb', line 7

def self.type_name
  "unknown"
end