Class: Fieldhand::Set
- Inherits:
-
Object
- Object
- Fieldhand::Set
- Defined in:
- lib/fieldhand/set.rb
Overview
A set is an optional construct for grouping items for the purpose of selective harvesting.
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#response_date ⇒ Object
readonly
Returns the value of attribute response_date.
Instance Method Summary collapse
-
#descriptions ⇒ Object
Return any descriptions of the set as an array of strings.
-
#initialize(element, response_date = Time.now) ⇒ Set
constructor
Return a Set with the given element and optional response date.
-
#name ⇒ Object
Return the set’s short human-readable name.
-
#spec ⇒ Object
Return the set’s unique identifier within the repository.
-
#to_s ⇒ Object
Return the set’s spec as its string representation.
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
#element ⇒ Object (readonly)
Returns the value of attribute element.
10 11 12 |
# File 'lib/fieldhand/set.rb', line 10 def element @element end |
#response_date ⇒ Object (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
#descriptions ⇒ Object
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 |
#name ⇒ Object
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 |
#spec ⇒ Object
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_s ⇒ Object
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 |