class TableSchema::Types::Integer

Public Class Methods

supported_constraints() click to toggle source
# File lib/tableschema/types/integer.rb, line 9
def self.supported_constraints
  [
    'required',
    'unique',
    'pattern',
    'enum',
    'minimum',
    'maximum',
  ]
end

Public Instance Methods

cast_default(value) click to toggle source
# File lib/tableschema/types/integer.rb, line 24
def cast_default(value)
  if value.nil? || value.is_a?(type)
    value
  else
    bare_number = @field.fetch(:bareNumber, TableSchema::DEFAULTS[:bare_number])
    if !bare_number
      value = value.gsub(/((^\D*)|(\D*$))/, '')
    end
    Integer(value)
  end
rescue ArgumentError
  raise TableSchema::InvalidCast.new("#{value} is not a #{name}")
end
name() click to toggle source
# File lib/tableschema/types/integer.rb, line 5
def name
  'integer'
end
type() click to toggle source
# File lib/tableschema/types/integer.rb, line 20
def type
  ::Integer
end