class FlatKit::FieldType::IntegerType

Constants

REGEX

Public Class Methods

coerce(data) click to toggle source
# File lib/flat_kit/field_type/integer_type.rb, line 24
def self.coerce(data)
  Integer(data)
rescue TypeError => _
  CoerceFailure
rescue ArgumentError => _
  CoerceFailure
end
matches?(data) click to toggle source
# File lib/flat_kit/field_type/integer_type.rb, line 11
def self.matches?(data)
  case data
  when Integer
    true
  when Float
    false
  when String
    REGEX.match?(data)
  else
    false
  end
end
type_name() click to toggle source
# File lib/flat_kit/field_type/integer_type.rb, line 7
def self.type_name
  "integer"
end