Class: Fieldhand::Header
- Inherits:
-
Object
- Object
- Fieldhand::Header
- Defined in:
- lib/fieldhand/header.rb
Overview
Contains the unique identifier of the item and properties necessary for selective harvesting. The header consists of the following parts:
-
the unique identifier – the unique identifier of an item in a repository;
-
the datestamp – the date of creation, modification or deletion of the record for the purpose of selective harvesting.
-
zero or more setSpec elements – the set membership of the item for the purpose of selective harvesting.
-
an optional status attribute with a value of deleted indicates the withdrawal of availability of the specified metadata format for the item, dependent on the repository support for deletions.
See www.openarchives.org/OAI/openarchivesprotocol.html#header
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#response_date ⇒ Object
readonly
Returns the value of attribute response_date.
Instance Method Summary collapse
-
#datestamp ⇒ Object
Return the UTC datestamp of this item.
-
#deleted? ⇒ Boolean
Test whether this item is marked as deleted or not.
-
#identifier ⇒ Object
Return the unique identifier of this item.
-
#initialize(element, response_date = Time.now) ⇒ Header
constructor
Return a new Header with the given element and an optional response date.
-
#sets ⇒ Object
Return any set memberships of this item.
-
#status ⇒ Object
Return the optional status of this item.
Constructor Details
#initialize(element, response_date = Time.now) ⇒ Header
Return a new Header with the given element and an optional response date.
Defaults the response date to the current time.
23 24 25 26 |
# File 'lib/fieldhand/header.rb', line 23 def initialize(element, response_date = Time.now) @element = element @response_date = response_date end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
18 19 20 |
# File 'lib/fieldhand/header.rb', line 18 def element @element end |
#response_date ⇒ Object (readonly)
Returns the value of attribute response_date.
18 19 20 |
# File 'lib/fieldhand/header.rb', line 18 def response_date @response_date end |
Instance Method Details
#datestamp ⇒ Object
Return the UTC datestamp of this item.
47 48 49 |
# File 'lib/fieldhand/header.rb', line 47 def datestamp @datestamp ||= Datestamp.parse(element.datestamp.text) end |
#deleted? ⇒ Boolean
Test whether this item is marked as deleted or not.
Note that a repository’s support for deleted records can be interrogated through the ‘Identify` request, see www.openarchives.org/OAI/openarchivesprotocol.html#DeletedRecords
32 33 34 |
# File 'lib/fieldhand/header.rb', line 32 def deleted? status == 'deleted' end |
#identifier ⇒ Object
Return the unique identifier of this item.
42 43 44 |
# File 'lib/fieldhand/header.rb', line 42 def identifier @identifier ||= element.identifier.text end |
#sets ⇒ Object
Return any set memberships of this item.
52 53 54 |
# File 'lib/fieldhand/header.rb', line 52 def sets @sets ||= element.locate('setSpec/^String') end |
#status ⇒ Object
Return the optional status of this item.
37 38 39 |
# File 'lib/fieldhand/header.rb', line 37 def status element['status'] end |