Class: Geojsonlint::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/geojsonlint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Parser

Returns a new instance of Parser.

Parameters:

  • data (String, Hash)


17
18
19
20
21
22
# File 'lib/geojsonlint.rb', line 17

def initialize(data)
  @data = data

  @schema = JSON.parse(File.read(File.expand_path("../geojsonlint/geojson_schema.json", __FILE__)))
  self
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



14
15
16
# File 'lib/geojsonlint.rb', line 14

def data
  @data
end

#schemaObject (readonly)

Returns the value of attribute schema.



14
15
16
# File 'lib/geojsonlint.rb', line 14

def schema
  @schema
end

Instance Method Details

#runGeojson

Returns:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/geojsonlint.rb', line 25

def run
  options = {
    errors_as_objects: true,
    validate_schema: true
  }

  geojson = Geojson.new
  geojson.errors = JSON::Validator.fully_validate(@schema, @data, **options)

  geojson
end