Class: GeoCombine::Geoblacklight
- Inherits:
-
Object
- Object
- GeoCombine::Geoblacklight
- Includes:
- Formats, GeometryTypes, Subjects
- Defined in:
- lib/geo_combine/geoblacklight.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#enhance_metadata ⇒ Object
Calls metadata enhancement methods for each key, value pair in the metadata hash.
-
#initialize(metadata, fields = {}) ⇒ Geoblacklight
constructor
Initializes a GeoBlacklight object GeoBlacklight-Schema.
-
#to_json ⇒ String
Returns a string of JSON from a GeoBlacklight hash.
-
#valid? ⇒ Boolean
Validates a GeoBlacklight-Schema json document.
Methods included from GeometryTypes
Methods included from Subjects
Methods included from Formats
Constructor Details
#initialize(metadata, fields = {}) ⇒ Geoblacklight
Initializes a GeoBlacklight object GeoBlacklight-Schema
14 15 16 |
# File 'lib/geo_combine/geoblacklight.rb', line 14 def initialize(, fields = {}) @metadata = JSON.parse().merge(fields) end |
Instance Attribute Details
#metadata ⇒ Object (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_metadata ⇒ Object
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_json ⇒ String
Returns a string of JSON from a GeoBlacklight hash
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
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 |