Class: Fieldhand::Header

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.



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

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.



16
17
18
# File 'lib/fieldhand/header.rb', line 16

def element
  @element
end

#response_dateObject (readonly)

Returns the value of attribute response_date.



16
17
18
# File 'lib/fieldhand/header.rb', line 16

def response_date
  @response_date
end

Instance Method Details

#datestampObject

Return the UTC datestamp of this item.



45
46
47
# File 'lib/fieldhand/header.rb', line 45

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

Returns:

  • (Boolean)


30
31
32
# File 'lib/fieldhand/header.rb', line 30

def deleted?
  status == 'deleted'
end

#identifierObject

Return the unique identifier of this item.



40
41
42
# File 'lib/fieldhand/header.rb', line 40

def identifier
  @identifier ||= element.identifier.text
end

#setsObject

Return any set memberships of this item.



50
51
52
# File 'lib/fieldhand/header.rb', line 50

def sets
  @sets ||= element.locate('setSpec/^String')
end

#statusObject

Return the optional status of this item.



35
36
37
# File 'lib/fieldhand/header.rb', line 35

def status
  element['status']
end