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 = Geoblacklight.configuration.fields.references) ⇒ References

Returns a new instance of References.



8
9
10
11
12
# File 'lib/geoblacklight/references.rb', line 8

def initialize(document, reference_field = Geoblacklight.configuration.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



69
70
71
72
73
74
75
# File 'lib/geoblacklight/references.rb', line 69

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.



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

#esri_webservicesObject

Returns all of the Esri webservices for given set of references



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

def esri_webservices
  %w[tiled_map_layer dynamic_map_layer feature_layer image_map_layer].filter_map do |layer_type|
    send(layer_type)
  end
end

#formatString

Accessor for a document's file format

Returns:

  • (String)

    file format for the document



35
36
37
# File 'lib/geoblacklight/references.rb', line 35

def format
  @document.file_format
end

#references(ref_type) ⇒ Geoblacklight::Reference

Parameters:

  • ref_type (String, Symbol)

Returns:



42
43
44
# File 'lib/geoblacklight/references.rb', line 42

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

#shown_metadataGeoblacklight::Metadata::Base

Return only metadata for shown metadata



28
29
30
# File 'lib/geoblacklight/references.rb', line 28

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



17
18
19
20
21
22
23
# File 'lib/geoblacklight/references.rb', line 17

def 
   = Geoblacklight.configuration.
   = @refs.select { |ref| .include?(ref.type.to_s) }
  .sort do |u, v|
    .index(u.type.to_s) <=> .index(v.type.to_s)
  end
end