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.



15
16
17
18
# File 'lib/fieldhand/set.rb', line 15

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.



10
11
12
# File 'lib/fieldhand/set.rb', line 10

def element
  @element
end

#response_dateObject (readonly)

Returns the value of attribute response_date.



10
11
12
# File 'lib/fieldhand/set.rb', line 10

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.



40
41
42
# File 'lib/fieldhand/set.rb', line 40

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

#nameObject

Return the set’s short human-readable name.



33
34
35
# File 'lib/fieldhand/set.rb', line 33

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

#specObject

Return the set’s unique identifier within the repository.



28
29
30
# File 'lib/fieldhand/set.rb', line 28

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.



23
24
25
# File 'lib/fieldhand/set.rb', line 23

def to_s
  spec
end