class JsonTableSchema::Field
Attributes
type_class[R]
Public Class Methods
new(descriptor)
click to toggle source
# File lib/jsontableschema/field.rb, line 7 def initialize(descriptor) self.merge! descriptor @type_class = get_type end
Public Instance Methods
cast_value(col)
click to toggle source
# File lib/jsontableschema/field.rb, line 28 def cast_value(col) klass = get_class_for_type(type) converter = Kernel.const_get(klass).new(self) converter.cast(col) end
constraints()
click to toggle source
# File lib/jsontableschema/field.rb, line 24 def constraints self['constraints'] || {} end
format()
click to toggle source
# File lib/jsontableschema/field.rb, line 20 def format self['format'] || 'default' end
name()
click to toggle source
# File lib/jsontableschema/field.rb, line 12 def name self['name'] end
type()
click to toggle source
# File lib/jsontableschema/field.rb, line 16 def type self['type'] || 'string' end
Private Instance Methods
get_type()
click to toggle source
# File lib/jsontableschema/field.rb, line 36 def get_type Object.const_get get_class_for_type(type) end