Class: OAI::Provider::Response::Identify

Inherits:
Base
  • Object
show all
Defined in:
lib/oai/provider/response/identify.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #provider

Instance Method Summary collapse

Methods inherited from Base

default_parameters, #initialize, required_parameters, #response, valid_parameters

Constructor Details

This class inherits a constructor from OAI::Provider::Response::Base

Instance Method Details

#to_xmlObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/oai/provider/response/identify.rb', line 5

def to_xml
  response do |r|
    r.Identify do
      r.repositoryName provider.name
      r.baseURL provider.url
      r.protocolVersion 2.0
      if provider.email and provider.email.respond_to?(:each)
        provider.email.each { |address| r.adminEmail address }
      else
        r.adminEmail provider.email.to_s
      end
      r.earliestDatestamp Time.parse(provider.model.earliest.to_s).utc.xmlschema
      r.deletedRecord provider.delete_support.to_s
      r.granularity provider.granularity
      r.description do
        r.tag! 'oai-identifier', 'xmlns' => 'http://www.openarchives.org/OAI/2.0/oai-identifier', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/oai-identifier http://www.openarchives.org/OAI/2.0/oai-identifier.xsd' do
          r.scheme 'oai'
          r.repositoryIdentifier provider.prefix.gsub(/oai:/, '')
          r.delimiter ':'
          r.sampleIdentifier "#{provider.prefix}:#{provider.identifier}"
        end
      end
      if provider.description
        r.target! << provider.description
      end
    end

  end
end