class Geojsonlint::Parser

Attributes

data[R]
schema[R]

Public Class Methods

new(data) click to toggle source

@param data [String, Hash]

# 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

Public Instance Methods

run() click to toggle source

@return [Geojson]

# 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