Class: OAI::Set

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

Overview

bundles up information about a set retrieved during a ListSets request

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from XPath

#get_attribute, #xpath, #xpath_all, #xpath_first

Constructor Details

#initialize(values = {}) ⇒ Set

Returns a new instance of Set.

Raises:



10
11
12
13
14
15
# File 'lib/oai/set.rb', line 10

def initialize(values = {})
  @name = values.delete(:name)
  @spec = values.delete(:spec)
  @description = values.delete(:description)
  raise ArgumentException, "Invalid options" unless values.empty?
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/oai/set.rb', line 8

def description
  @description
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/oai/set.rb', line 8

def name
  @name
end

#specObject

Returns the value of attribute spec.



8
9
10
# File 'lib/oai/set.rb', line 8

def spec
  @spec
end

Class Method Details

.parse(element) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/oai/set.rb', line 17

def self.parse(element)
  set = self.new
  set.name = set.xpath(element, './/setName')
  set.spec = set.xpath(element, './/setSpec')
  set.description = set.xpath_first(element, './/setDescription')
  set
end

Instance Method Details

#to_sObject



25
26
27
# File 'lib/oai/set.rb', line 25

def to_s
  "#{@name} [#{@spec}]"
end