Class: Fieldhand::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/fieldhand/set.rb

Overview

A set is an optional construct for grouping items for the purpose of selective harvesting.

See www.openarchives.org/OAI/openarchivesprotocol.html#Set

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, response_date = Time.now) ⇒ Set

Return a Set with the given element and optional response date.

Defaults the response date to the current time.



13
14
15
16
# File 'lib/fieldhand/set.rb', line 13

def initialize(element, response_date = Time.now)
  @element = element
  @response_date = response_date
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



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

def element
  @element
end

#response_dateObject (readonly)

Returns the value of attribute response_date.



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

def response_date
  @response_date
end

Instance Method Details

#descriptionsObject

Return any descriptions of the set as an array of strings.

As descriptions can be in any format, Fieldhand does not attempt to parse them but leave this to the user.



38
39
40
# File 'lib/fieldhand/set.rb', line 38

def descriptions
  @descriptions ||= element.locate('setDescription').map { |description| Ox.dump(description) }
end

#nameObject

Return the set’s short human-readable name.



31
32
33
# File 'lib/fieldhand/set.rb', line 31

def name
  @name ||= element.setName.text
end

#specObject

Return the set’s unique identifier within the repository.



26
27
28
# File 'lib/fieldhand/set.rb', line 26

def spec
  @spec ||= element.setSpec.text
end

#to_sObject

Return the set’s spec as its string representation.

This means that Sets can be used as arguments that expect a set spec.



21
22
23
# File 'lib/fieldhand/set.rb', line 21

def to_s
  spec
end