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.
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
#element ⇒ Object (readonly)
Returns the value of attribute element.
11 12 13 |
# File 'lib/fieldhand/record.rb', line 11 def element @element end |
#response_date ⇒ Object (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
#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.
65 66 67 |
# File 'lib/fieldhand/record.rb', line 65 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.
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
25 26 27 |
# File 'lib/fieldhand/record.rb', line 25 def deleted? header.deleted? end |
#header ⇒ Object
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 |
#identifier ⇒ Object
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 |
#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.
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 |
#sets ⇒ Object
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 |
#status ⇒ Object
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_xml ⇒ Object
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 |