Class: Fieldhand::MetadataFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/fieldhand/metadata_format.rb

Overview

A metadata format supported by the repository.

See www.openarchives.org/OAI/openarchivesprotocol.html#ListMetadataFormats

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, response_date = Time.now) ⇒ MetadataFormat

Return a new Metadata Format for the given element with an optional response date.

The response date defaults to the current time.



13
14
15
16
# File 'lib/fieldhand/metadata_format.rb', line 13

def initialize(element, response_date = Time.now)
  @element = element
  @response_date = response_date
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



8
9
10
# File 'lib/fieldhand/metadata_format.rb', line 8

def element
  @element
end

#response_dateObject (readonly)

Returns the value of attribute response_date.



8
9
10
# File 'lib/fieldhand/metadata_format.rb', line 8

def response_date
  @response_date
end

Instance Method Details

#namespaceObject

Return the XML Namespace URI for the format.



36
37
38
# File 'lib/fieldhand/metadata_format.rb', line 36

def namespace
  @namespace ||= URI(element.metadataNamespace.text)
end

#prefixObject

Return the string metadata prefix for the format.



26
27
28
# File 'lib/fieldhand/metadata_format.rb', line 26

def prefix
  @prefix ||= element.metadataPrefix.text
end

#schemaObject

Return the location of an XML Schema describing the format as a URI.



31
32
33
# File 'lib/fieldhand/metadata_format.rb', line 31

def schema
  @schema ||= URI(element.schema.text)
end

#to_sObject

Return the prefix as a string representation of the format.

This makes it possible to pass a Metadata Format to methods that expect a string metadata prefix.



21
22
23
# File 'lib/fieldhand/metadata_format.rb', line 21

def to_s
  prefix
end