Class: Sword2Ruby::SwordStatementOAIORE

Inherits:
Object
  • Object
show all
Defined in:
lib/sword2ruby/sword_statement_oai_ore.rb

Overview

This class models the OAI-ORE Sword Statement.

For more information, see the Sword2 specification: section 11.3. “OAI-ORE Serialisation”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sword_statement_uri, connection) ⇒ SwordStatementOAIORE

Creates a new SwordStatementOAIORE object, using the supplied URI and connection object.

Parameters

sword_statement_uri

The URI string to the OAI-ORE Sword Statement.

connection

Sword2Ruby::Connection object used to perform the operation.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sword2ruby/sword_statement_oai_ore.rb', line 19

def initialize(sword_statement_uri, connection)
  #Validate parameters
  Utility.check_argument_class('sword_statement_uri', sword_statement_uri, String)
  Utility.check_argument_class('connection', connection, Connection)
  
  response = connection.get(sword_statement_uri)

  if response.is_a? Net::HTTPSuccess
     @statement_document = REXML::Document.new(response.body)
     @rdf_descriptions = []
     @statement_document.elements.each("/rdf:RDF/rdf:Description") do |description|
       @rdf_descriptions << description
     end
   else
     raise Sword2Ruby::Exception.new("Failed to do get(#{sword_statement_uri}): server returned code #{response.code} #{response.message}")   
  end
end

Instance Attribute Details

#rdf_descriptionsObject (readonly)

An array of rdf:descriptions. See the overload methods in REXML::Element for each description’s methods.



13
14
15
# File 'lib/sword2ruby/sword_statement_oai_ore.rb', line 13

def rdf_descriptions
  @rdf_descriptions
end

#statement_documentObject (readonly)

The complete statement document, returned as a REXML::Document.



10
11
12
# File 'lib/sword2ruby/sword_statement_oai_ore.rb', line 10

def statement_document
  @statement_document
end