Class: Geoblacklight::References
- Inherits:
-
Object
- Object
- Geoblacklight::References
- Defined in:
- lib/geoblacklight/references.rb
Overview
References is a geoblacklight-schema dct:references parser
Instance Attribute Summary collapse
-
#reference_field ⇒ Object
readonly
Returns the value of attribute reference_field.
-
#refs ⇒ Object
readonly
Returns the value of attribute refs.
Instance Method Summary collapse
-
#download_types ⇒ Hash?
Generated download types from wxs services.
-
#downloads_by_format ⇒ Hash?
Download hash based off of format type.
-
#esri_webservices ⇒ Object
Returns all of the Esri webservices for given set of references.
-
#format ⇒ String
Accessor for a document’s file format.
-
#initialize(document, reference_field = Settings.FIELDS.REFERENCES) ⇒ References
constructor
A new instance of References.
-
#preferred_download ⇒ Hash?
Preferred download (should be a file download).
- #references(ref_type) ⇒ Geoblacklight::Reference
-
#shown_metadata ⇒ Geoblacklight::Metadata::Base
Return only metadata for shown metadata.
-
#shown_metadata_refs ⇒ Geoblacklight::Reference
Return only those metadata references which are exposed within the configuration.
Constructor Details
#initialize(document, reference_field = Settings.FIELDS.REFERENCES) ⇒ References
Returns a new instance of References.
7 8 9 10 11 |
# File 'lib/geoblacklight/references.rb', line 7 def initialize(document, reference_field = Settings.FIELDS.REFERENCES) @document = document @reference_field = reference_field @refs = parse_references.map { |ref| Reference.new(ref) } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &b) ⇒ Object (private)
Adds a call to references for defined URI keys
129 130 131 132 133 134 135 |
# File 'lib/geoblacklight/references.rb', line 129 def method_missing(m, *args, &b) if Geoblacklight::Constants::URI.key?(m) references m else super end end |
Instance Attribute Details
#reference_field ⇒ Object (readonly)
Returns the value of attribute reference_field.
6 7 8 |
# File 'lib/geoblacklight/references.rb', line 6 def reference_field @reference_field end |
#refs ⇒ Object (readonly)
Returns the value of attribute refs.
6 7 8 |
# File 'lib/geoblacklight/references.rb', line 6 def refs @refs end |
Instance Method Details
#download_types ⇒ Hash?
Generated download types from wxs services
68 69 70 |
# File 'lib/geoblacklight/references.rb', line 68 def download_types downloads_by_format end |
#downloads_by_format ⇒ Hash?
Download hash based off of format type
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/geoblacklight/references.rb', line 54 def downloads_by_format case format when "Shapefile" vector_download_formats when "GeoTIFF" geotiff_download_formats when "ArcGRID" arcgrid_download_formats end end |
#esri_webservices ⇒ Object
Returns all of the Esri webservices for given set of references
74 75 76 77 78 |
# File 'lib/geoblacklight/references.rb', line 74 def esri_webservices %w[tiled_map_layer dynamic_map_layer feature_layer image_map_layer].map do |layer_type| send(layer_type) end.compact end |
#format ⇒ String
Accessor for a document’s file format
33 34 35 |
# File 'lib/geoblacklight/references.rb', line 33 def format @document[Settings.FIELDS.FORMAT] end |
#preferred_download ⇒ Hash?
Preferred download (should be a file download)
47 48 49 |
# File 'lib/geoblacklight/references.rb', line 47 def preferred_download file_download if download.present? end |
#references(ref_type) ⇒ Geoblacklight::Reference
40 41 42 |
# File 'lib/geoblacklight/references.rb', line 40 def references(ref_type) @refs.find { |reference| reference.type == ref_type } end |
#shown_metadata ⇒ Geoblacklight::Metadata::Base
Return only metadata for shown metadata
26 27 28 |
# File 'lib/geoblacklight/references.rb', line 26 def @shown_metadata ||= .map { |ref| Geoblacklight::Metadata.instance(ref) } end |
#shown_metadata_refs ⇒ Geoblacklight::Reference
Return only those metadata references which are exposed within the configuration
16 17 18 19 20 21 |
# File 'lib/geoblacklight/references.rb', line 16 def = @refs.select { |ref| Settings.METADATA_SHOWN.include?(ref.type.to_s) } .sort do |u, v| Settings.METADATA_SHOWN.index(u.type.to_s) <=> Settings.METADATA_SHOWN.index(v.type.to_s) end end |