Class: GeoCombine::Geoblacklight

Inherits:
Object
  • Object
show all
Includes:
Formats, GeometryTypes, Subjects
Defined in:
lib/geo_combine/geoblacklight.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GeometryTypes

#geometry_types

Methods included from Subjects

#subjects

Methods included from Formats

#formats

Constructor Details

#initialize(metadata, fields = {}) ⇒ Geoblacklight

Initializes a GeoBlacklight object GeoBlacklight-Schema

Parameters:

  • metadata (String)

    be a valid JSON string document in

  • fields (Hash) (defaults to: {})

    enhancements to metadata that are merged with @metadata



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

def initialize(, fields = {})
  @metadata = JSON.parse().merge(fields)
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/geo_combine/geoblacklight.rb', line 7

def 
  @metadata
end

Instance Method Details

#enhance_metadataObject

Calls metadata enhancement methods for each key, value pair in the metadata hash



21
22
23
24
25
26
27
28
29
# File 'lib/geo_combine/geoblacklight.rb', line 21

def 
  @metadata.each do |key, value|
    translate_formats(key, value)
    enhance_subjects(key, value)
    format_proper_date(key, value)
    fields_should_be_array(key, value)
    translate_geometry_type(key, value)
  end
end

#to_jsonString

Returns a string of JSON from a GeoBlacklight hash

Returns:

  • (String)


34
35
36
# File 'lib/geo_combine/geoblacklight.rb', line 34

def to_json
  @metadata.to_json
end

#valid?Boolean

Validates a GeoBlacklight-Schema json document

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/geo_combine/geoblacklight.rb', line 41

def valid?
  schema = JSON.parse(File.read(File.join(File.dirname(__FILE__), '../schema/geoblacklight-schema.json')))
  JSON::Validator.validate!(schema, to_json, validate_schema: true)
end