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.



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

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



128
129
130
131
132
133
134
# File 'lib/geoblacklight/references.rb', line 128

def method_missing(m, *args, &b)
  if Geoblacklight::Constants::URI.key?(m)
    references m
  else
    super
  end
end

Instance Attribute Details

#reference_fieldObject (readonly)

Returns the value of attribute reference_field.



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

def reference_field
  @reference_field
end

#refsObject (readonly)

Returns the value of attribute refs.



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

def refs
  @refs
end

Instance Method Details

#download_typesHash?

Generated download types from wxs services

Returns:

  • (Hash, nil)


67
68
69
# File 'lib/geoblacklight/references.rb', line 67

def download_types
  downloads_by_format
end

#downloads_by_formatHash?

Download hash based off of format type

Returns:

  • (Hash, nil)


53
54
55
56
57
58
59
60
61
62
# File 'lib/geoblacklight/references.rb', line 53

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



73
74
75
76
77
# File 'lib/geoblacklight/references.rb', line 73

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



32
33
34
# File 'lib/geoblacklight/references.rb', line 32

def format
  @document[Settings.FIELDS.FILE_FORMAT]
end

#preferred_downloadHash?

Preferred download (should be a file download)

Returns:

  • (Hash, nil)


46
47
48
# File 'lib/geoblacklight/references.rb', line 46

def preferred_download
  return file_download if download.present?
end

#references(ref_type) ⇒ Geoblacklight::Reference

Parameters:

  • ref_type (String, Symbol)

Returns:



39
40
41
# File 'lib/geoblacklight/references.rb', line 39

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

#shown_metadataGeoblacklight::Metadata::Base

Return only metadata for shown metadata



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

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

#shown_metadata_refsGeoblacklight::Reference

Return only those metadata references which are exposed within the configuration



15
16
17
18
19
20
# File 'lib/geoblacklight/references.rb', line 15

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