Class: Fieldhand::Record
- Inherits:
-
Object
- Object
- Fieldhand::Record
- 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
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#response_date ⇒ Object
readonly
Returns the value of attribute response_date.
Instance Method Summary collapse
-
#about ⇒ Object
Return any about elements describing the metadata of this record as an array of strings.
-
#datestamp ⇒ Object
Return the UTC datestamp of this item according to its header as a ‘Date` or `Time` depending on the granularity of this repository.
-
#deleted? ⇒ Boolean
Test whether this item is marked as deleted or not according to its header.
-
#header ⇒ Object
Return the associated Header for this record.
-
#identifier ⇒ Object
Return the unique identifier of this item according to its header.
-
#initialize(element, response_date = Time.now) ⇒ Record
constructor
Return a new Record for the given element with an optional response date.
-
#metadata ⇒ Object
Return the single manifestation of the metadata of this item as a string, if present.
-
#sets ⇒ Object
Return any set memberships of this item according to its header.
-
#status ⇒ Object
Return the optional status of this item according to its header.
-
#to_xml ⇒ Object
Return this whole item as a string.
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.
14 15 16 17 |
# File 'lib/fieldhand/record.rb', line 14 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.
9 10 11 |
# File 'lib/fieldhand/record.rb', line 9 def element @element end |
#response_date ⇒ Object (readonly)
Returns the value of attribute response_date.
9 10 11 |
# File 'lib/fieldhand/record.rb', line 9 def response_date @response_date end |
Instance Method Details
#about ⇒ Object
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.
63 64 65 |
# File 'lib/fieldhand/record.rb', line 63 def about @about ||= element.locate('about').map { |about| Ox.dump(about) } end |
#datestamp ⇒ Object
Return the UTC datestamp of this item according to its header as a ‘Date` or `Time` depending on the granularity of this repository.
39 40 41 |
# File 'lib/fieldhand/record.rb', line 39 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
23 24 25 |
# File 'lib/fieldhand/record.rb', line 23 def deleted? header.deleted? end |
#header ⇒ Object
Return the associated Header for this record.
68 69 70 |
# File 'lib/fieldhand/record.rb', line 68 def header @header ||= Header.new(element.header) end |
#identifier ⇒ Object
Return the unique identifier of this item according to its header.
33 34 35 |
# File 'lib/fieldhand/record.rb', line 33 def identifier header.identifier end |
#metadata ⇒ Object
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.
56 57 58 |
# File 'lib/fieldhand/record.rb', line 56 def @metadata ||= element.locate('metadata[0]').map { || Ox.dump(, :encoding => 'utf-8', :indent => -1) }.first end |
#sets ⇒ Object
Return any set memberships of this item according to its header.
44 45 46 |
# File 'lib/fieldhand/record.rb', line 44 def sets header.sets end |
#status ⇒ Object
Return the optional status of this item according to its header.
28 29 30 |
# File 'lib/fieldhand/record.rb', line 28 def status header.status end |
#to_xml ⇒ Object
Return this whole item as a string
49 50 51 |
# File 'lib/fieldhand/record.rb', line 49 def to_xml Ox.dump(element, :encoding => 'utf-8', :indent => -1) end |