Class: Geoblacklight::Metadata

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

Instance Method Summary collapse

Constructor Details

#initialize(reference) ⇒ Metadata

Instantiates a Geoblacklight::Metadata object used for retrieving and formatting metadata

Parameters:


8
9
10
# File 'lib/geoblacklight/metadata.rb', line 8

def initialize(reference)
  @reference = reference
end

Instance Method Details

#metadataString

Handles metadata and returns the retrieved metadata or an error message if something went wrong

Returns:

  • (String)

    returned metadata string


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

def 
  response = 
  if response.nil? || response.status == 404
    Geoblacklight.logger.error "Could not reach #{@reference.endpoint}"
    return "Could not reach #{@reference.endpoint}"
  else
    return response.body
  end
end

#retrieve_metadataFaraday::Response?

Retrieves metadata from a url source connection error

Returns:

  • (Faraday::Response, nil)

    Faraday::Response or nil if there is a


30
31
32
33
34
35
36
37
38
39
# File 'lib/geoblacklight/metadata.rb', line 30

def 
  conn = Faraday.new(url: @reference.endpoint)
  conn.get
rescue Faraday::Error::ConnectionFailed => error
  Geoblacklight.logger.error error.inspect
  nil
rescue Faraday::Error::TimeoutError => error
  Geoblacklight.logger.error error.inspect
  nil
end