Class: JsonTableSchema::Types::GeoJSON

Inherits:
Base
  • Object
show all
Defined in:
lib/jsontableschema/types/geojson.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#cast, #initialize, #set_format, #test

Methods included from Helpers

#convert_to_boolean, #false_values, #get_class_for_type, #true_values, #type_class_lookup

Constructor Details

This class inherits a constructor from JsonTableSchema::Types::Base

Class Method Details

.supported_constraintsObject



9
10
11
12
13
14
15
# File 'lib/jsontableschema/types/geojson.rb', line 9

def self.supported_constraints
  [
    'required',
    'pattern',
    'enum'
  ]
end

Instance Method Details

#cast_default(value) ⇒ Object



21
22
23
24
25
26
27
# 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

#nameObject



5
6
7
# File 'lib/jsontableschema/types/geojson.rb', line 5

def name
  'geojson'
end

#typeObject



17
18
19
# File 'lib/jsontableschema/types/geojson.rb', line 17

def type
  ::Hash
end