Class: Geoblacklight::References

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

Overview

References is a geoblacklight-schema dct:references parser

Instance Attribute Summary collapse

Instance Method Summary collapse

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



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/geoblacklight/references.rb', line 137

def method_missing(m, *args, &b)
  if Geoblacklight::Constants::URI.key?(m)
    if m == :hgl
      Geoblacklight.deprecation.warn(
        "Geoblacklight::References#hgl and Geoblacklight::Constants::URI[:hgl] are " \
        "deprecated; the Harvard Geospatial Library download integration is removed " \
        "without replacement in GeoBlacklight 5"
      )
    end
    references m
  else
    super
  end
end

Instance Attribute Details

#reference_fieldObject (readonly)

Returns the value of attribute reference_field.



6
7
8
# File 'lib/geoblacklight/references.rb', line 6

def reference_field
  @reference_field
end

#refsObject (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_typesHash?

Generated download types from wxs services

Returns:

  • (Hash, nil)


76
77
78
# File 'lib/geoblacklight/references.rb', line 76

def download_types
  downloads_by_format
end

#downloads_by_formatHash?

Download hash based off of format type

Returns:

  • (Hash, nil)


62
63
64
65
66
67
68
69
70
71
# File 'lib/geoblacklight/references.rb', line 62

def downloads_by_format
  case format
  when "Shapefile"
    vector_download_formats
  when "GeoTIFF"
    geotiff_download_formats
  when "ArcGRID"
    arcgrid_download_formats
  end
end

#esri_webservicesObject

Returns all of the Esri webservices for given set of references



82
83
84
85
86
# File 'lib/geoblacklight/references.rb', line 82

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

#formatString

Accessor for a document's file format

Returns:

  • (String)

    file format for the document



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/geoblacklight/references.rb', line 33

def format
  unless @document.respond_to?(:file_format)
    Geoblacklight.deprecation.warn(
      "Geoblacklight::References reads the format with @document[#{Settings.FIELDS.FORMAT}] in " \
      "GeoBlacklight 4 and @document.file_format in GeoBlacklight 5, but the document you passed " \
      "(#{@document.class}) does not respond to #file_format; pass an object that includes " \
      "Geoblacklight::SolrDocument, or define #file_format on it"
    )
  end
  @document[Settings.FIELDS.FORMAT]
end

#preferred_downloadHash?

Preferred download (should be a file download)

Returns:

  • (Hash, nil)


55
56
57
# File 'lib/geoblacklight/references.rb', line 55

def preferred_download
  file_download if download.present?
end

#references(ref_type) ⇒ Geoblacklight::Reference

Parameters:

  • ref_type (String, Symbol)

Returns:



48
49
50
# File 'lib/geoblacklight/references.rb', line 48

def references(ref_type)
  @refs.find { |reference| reference.type == ref_type }
end

#shown_metadataGeoblacklight::Metadata::Base

Return only metadata for shown metadata



26
27
28
# File 'lib/geoblacklight/references.rb', line 26

def 
   ||= .map { |ref| Geoblacklight::.instance(ref) }
end

#shown_metadata_refsGeoblacklight::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..include?(ref.type.to_s) }
  .sort do |u, v|
    Settings..index(u.type.to_s) <=> Settings..index(v.type.to_s)
  end
end