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.



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

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



99
100
101
102
103
104
105
# File 'lib/geoblacklight/references.rb', line 99

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.



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

def reference_field
  @reference_field
end

#refsObject (readonly)

Returns the value of attribute refs.



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

def refs
  @refs
end

Instance Method Details

#download_typesHash?

Generated download types from wxs services

Returns:

  • (Hash, nil)


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

def download_types
  downloads_by_format
end

#downloads_by_formatHash?

Download hash based off of format type

Returns:

  • (Hash, nil)


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

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

#formatString

Accessor for a document’s file format

Returns:

  • (String)

    file format for the document



14
15
16
# File 'lib/geoblacklight/references.rb', line 14

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

#preferred_downloadHash?

Preferred download (should be a file download)

Returns:

  • (Hash, nil)


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

def preferred_download
  return file_download unless download.blank?
end

#references(ref_type) ⇒ Geoblacklight::Reference

Parameters:

  • ref_type (String, Symbol)

Returns:



21
22
23
# File 'lib/geoblacklight/references.rb', line 21

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