class JsonTableSchema::Types::GeoJSON
Public Class Methods
supported_constraints()
click to toggle source
# File lib/jsontableschema/types/geojson.rb, line 9 def self.supported_constraints [ 'required', 'pattern', 'enum' ] end
Public Instance Methods
cast_default(value)
click to toggle source
# File lib/jsontableschema/types/geojson.rb, line 21 def cast_default(value) value = JSON.parse(value) if !value.is_a?(type) JSON::Validator.validate!(geojson_schema, value) value rescue JSON::Schema::ValidationError, JSON::ParserError raise JsonTableSchema::InvalidGeoJSONType.new("#{value} is not valid GeoJSON") end
name()
click to toggle source
# File lib/jsontableschema/types/geojson.rb, line 5 def name 'geojson' end
type()
click to toggle source
# File lib/jsontableschema/types/geojson.rb, line 17 def type ::Hash end
Private Instance Methods
geojson_schema()
click to toggle source
# File lib/jsontableschema/types/geojson.rb, line 31 def geojson_schema path = File.join( File.dirname(__FILE__), "..", "..", "..", "etc", "schemas", "geojson.json" ) @geojson_schema ||= JSON.parse File.read(path) end