Class: GeoCombine::Geoblacklight

Inherits:
Metadata
  • Object
show all
Defined in:
lib/geo_combine/geoblacklight.rb

Instance Attribute Summary

Attributes inherited from Metadata

#metadata

Instance Method Summary collapse

Methods inherited from Metadata

#initialize, #to_geoblacklight, #to_html

Constructor Details

This class inherits a constructor from GeoCombine::Metadata

Instance Method Details

#to_hashHash

Returns a hash from a GeoBlacklight object

Returns:

  • (Hash)

14
15
16
17
18
19
20
21
22
23
# File 'lib/geo_combine/geoblacklight.rb', line 14

def to_hash
  hash = {}
  @metadata.css('field').each do |field|
    (hash[field.attributes['name'].value] ||= []) << field.children.text
  end
  hash.collect do |key, value|
    hash[key] = value.count > 1 ? { key => value } : { key => value[0] }
  end
  hash
end

#to_jsonString

Returns a string of JSON from a GeoBlacklight hash

Returns:

  • (String)

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

def to_json
  to_hash.to_json
end