Class: Fieldhand::Identify

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Return a new Identify with the given element and optional response date.

Defaults the response date to the current time.



14
15
16
17
# File 'lib/fieldhand/identify.rb', line 14

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.



9
10
11
# File 'lib/fieldhand/identify.rb', line 9

def element
  @element
end

#response_dateObject (readonly)

Returns the value of attribute response_date.



9
10
11
# File 'lib/fieldhand/identify.rb', line 9

def response_date
  @response_date
end

Instance Method Details

#admin_emailsObject

Return any e-mail addresses of administrators of the repository as an array of strings.



64
65
66
# File 'lib/fieldhand/identify.rb', line 64

def admin_emails
  @admin_emails ||= element.locate('adminEmail/^String')
end

#base_urlObject

Return the base URL of the repository as a URI.

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



27
28
29
# File 'lib/fieldhand/identify.rb', line 27

def base_url
  @base_url ||= URI(element.baseURL.text)
end

#compressionObject

Return any compression encodings supported by the repository as an array of strings.



69
70
71
# File 'lib/fieldhand/identify.rb', line 69

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

#deleted_recordObject

Return the manner in which the repository supports the notion of deleted records as a string.

Possible values are:

  • no

  • transient

  • persistent

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



51
52
53
# File 'lib/fieldhand/identify.rb', line 51

def deleted_record
  @deleted_record ||= element.deletedRecord.text
end

#descriptionsObject

Return any raw description elements used by communities to describe their repositories as an array of strings.

As these can be in any format, Fieldhand does not attempt to parse the elements but leaves that to users.



76
77
78
# File 'lib/fieldhand/identify.rb', line 76

def descriptions
  @descriptions ||= element.locate('description')
end

#earliest_datestampObject

Return the guaranteed lower limit of all datestamps recording changes, modifications, or deletions in the repository as a ‘Date` or `Time` depending on the granularity of the repository.



38
39
40
# File 'lib/fieldhand/identify.rb', line 38

def earliest_datestamp
  @earliest_datestamp ||= Datestamp.parse(element.earliestDatestamp.text)
end

#granularityObject

Return the finest harvesting granularity supported by the repository. The legitimate values are YYYY-MM-DD and YYYY-MM-DDThh:mm:ssZ with meanings as defined in ISO 8601.

See www.w3.org/TR/NOTE-datetime



59
60
61
# File 'lib/fieldhand/identify.rb', line 59

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

#nameObject

Return the human readable name for the repository.



20
21
22
# File 'lib/fieldhand/identify.rb', line 20

def name
  @name ||= element.repositoryName.text
end

#protocol_versionObject

Return the version of the OAI-PMH protocol supported by the repository as a string.



32
33
34
# File 'lib/fieldhand/identify.rb', line 32

def protocol_version
  @protocol_version ||= element.protocolVersion.text
end