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.
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
#element ⇒ Object (readonly)
Returns the value of attribute element.
8 9 10 |
# File 'lib/fieldhand/set.rb', line 8 def element @element end |
#response_date ⇒ Object (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
#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.
38 39 40 |
# File 'lib/fieldhand/set.rb', line 38 def descriptions @descriptions ||= element.locate('setDescription').map { |description| Ox.dump(description) } end |
#name ⇒ Object
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 |
#spec ⇒ Object
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_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.
21 22 23 |
# File 'lib/fieldhand/set.rb', line 21 def to_s spec end |