Class: OAI::Record

Inherits:
Object
  • Object
show all
Includes:
XPath
Defined in:
lib/oai/client/record.rb

Overview

A class for representing a Record as returned from a ‘GetRecord` or `ListRecords` request. Each record will have a header and metadata attribute. The header is a Header object and the metadata is a `REXML::Element` object for that chunk of XML.

Note: if your Client was configured to use the ‘libxml’ parser metadata will return a ‘XML::Node` object instead.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XPath

#get_attribute, #xpath, #xpath_all, #xpath_first

Constructor Details

#initialize(element) ⇒ Record

Returns a new instance of Record.



14
15
16
17
18
19
# File 'lib/oai/client/record.rb', line 14

def initialize(element)
  @_source = element
  @header = OAI::Header.new xpath_first(element, './/header')
  @metadata = xpath_first(element, './/metadata')
  @about = xpath_first(element, './/about')
end

Instance Attribute Details

#_sourceObject

Returns the value of attribute _source.



12
13
14
# File 'lib/oai/client/record.rb', line 12

def _source
  @_source
end

#aboutObject

Returns the value of attribute about.



12
13
14
# File 'lib/oai/client/record.rb', line 12

def about
  @about
end

#headerObject

Returns the value of attribute header.



12
13
14
# File 'lib/oai/client/record.rb', line 12

def header
  @header
end

#metadataObject

Returns the value of attribute metadata.



12
13
14
# File 'lib/oai/client/record.rb', line 12

def 
  @metadata
end

Instance Method Details

#deleted?Boolean

a convenience method which digs into the header status attribute and returns true if the value is set to ‘deleted’

Returns:

  • (Boolean)


23
24
25
# File 'lib/oai/client/record.rb', line 23

def deleted?
  return @header.deleted?
end