Class: Fieldhand::Record

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

Overview

A record is metadata expressed in a single format.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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

Defaults the response date to the current time.



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

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.



11
12
13
# File 'lib/fieldhand/record.rb', line 11

def element
  @element
end

#response_dateObject (readonly)

Returns the value of attribute response_date.



11
12
13
# File 'lib/fieldhand/record.rb', line 11

def response_date
  @response_date
end

Instance Method Details

#aboutObject

Return any about elements describing the metadata of this record as an array of strings.

As about elements can be in any format, Fieldhand does not attempt to parse them but leave that to the user.



65
66
67
# File 'lib/fieldhand/record.rb', line 65

def about
  @about ||= element.locate('about').map { |about| Ox.dump(about) }
end

#datestampObject

Return the UTC datestamp of this item according to its header as a ‘Date` or `Time` depending on the granularity of this repository.



41
42
43
# File 'lib/fieldhand/record.rb', line 41

def datestamp
  header.datestamp
end

#deleted?Boolean

Test whether this item is marked as deleted or not according to its header.

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)


25
26
27
# File 'lib/fieldhand/record.rb', line 25

def deleted?
  header.deleted?
end

#headerObject

Return the associated Header for this record.



70
71
72
# File 'lib/fieldhand/record.rb', line 70

def header
  @header ||= Header.new(element.header)
end

#identifierObject

Return the unique identifier of this item according to its header.



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

def identifier
  header.identifier
end

#metadataObject

Return the single manifestation of the metadata of this item as a string, if present.

As metadata can be in any format, Fieldhand does not attempt to parse it but leave that to the user.



58
59
60
# File 'lib/fieldhand/record.rb', line 58

def 
  @metadata ||= element.locate('metadata[0]').map { || Ox.dump(, :encoding => 'utf-8', :indent => -1) }.first
end

#setsObject

Return any set memberships of this item according to its header.



46
47
48
# File 'lib/fieldhand/record.rb', line 46

def sets
  header.sets
end

#statusObject

Return the optional status of this item according to its header.



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

def status
  header.status
end

#to_xmlObject

Return this whole item as a string



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

def to_xml
  Ox.dump(element, :encoding => 'utf-8', :indent => -1)
end