Class: Datacite::Mapping::Resource
- Inherits:
-
Object
- Object
- Datacite::Mapping::Resource
- Extended by:
- Gem::Deprecate
- Includes:
- XML::MappingExtensions::Namespaced
- Defined in:
- lib/datacite/mapping/resource.rb
Overview
A collection of metadata properties chosen for the accurate and consistent identification of a resource for citation and retrieval purposes, along with recommended use instructions. The resource that is being identified can be of any kind, but it is typically a dataset.
Instance Attribute Summary collapse
-
#alternate_identifiers ⇒ Array<AlternateIdentifier>
An identifier or identifiers other than the primary Identifier applied to the resource being registered.
-
#contributors ⇒ Array<Contributor>
Institutions or persons responsible for collecting, creating, or otherwise contributing to the developement of the dataset.
-
#creators ⇒ Array<Creator>
The main researchers involved working on the data, or the authors of the publication in priority order.
-
#dates ⇒ Array<Date>
Different dates relevant to the work.
-
#descriptions ⇒ Array<Description>
All additional information that does not fit in any of the other categories.
-
#formats ⇒ Array<String>
Technical format of the resource, e.g.
-
#fundingReferences ⇒ Array<FundingReference>
Information about financial support (funding) for the resource being registered.
-
#geo_locations ⇒ Array<GeoLocations>
Spatial region or named place where the data was gathered or about which the data is focused.
-
#identifier ⇒ Identifier
A persistent identifier that identifies a resource.
-
#language ⇒ String
Primary language of the resource: an IETF BCP 47, ISO 639-1 language code.
-
#publication_year ⇒ Integer
Year when the resource is made publicly available.
-
#publisher ⇒ Publisher
The name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource.
-
#related_identifiers ⇒ Array<RelatedIdentifier>
Identifiers of related resources.
-
#resource_type ⇒ ResourceType?
The type of the resource.
-
#rights_list ⇒ Array<Rights>
Rights information for this resource.
-
#sizes ⇒ Array<String>
Unstructured size information about the resource.
-
#subjects ⇒ Array<Subject>
Subjects, keywords, classification codes, or key phrases describing the resource.
-
#titles ⇒ Array<Title>
The names or titles by which a resource is known.
-
#version ⇒ String
Version number of the resource.
Instance Method Summary collapse
-
#creator_affiliations ⇒ Array[Array[String]]
Convenience method to get the creators' affiliations.
-
#creator_names ⇒ [Array[String]] An array of the creators' names.
Convenience method to get the creators' names.
-
#fill_into_xml(xml, options = { mapping: :_default })
Overrides Namespaced::InstanceMethods.fill_into_xml to check mapping.
-
#funder_contrib ⇒ Contributor?
Convenience method to get the funding contributor.
-
#funder_id ⇒ NameIdentifier?
Convenience method to get the funding contributor identifier.
-
#funder_id_value ⇒ String?
Convenience method to get the funding contributor identifier as a string.
-
#funder_name ⇒ String?
deprecated
Deprecated.
contributor type 'funder' is deprecated. Use FundingReference instead.
- #funding_references=(value)
-
#initialize(identifier:, creators:, titles:, publisher:, publication_year:, subjects: [], contributors: [], dates: [], language: nil, funding_references: [], resource_type: nil, alternate_identifiers: [], related_identifiers: [], sizes: [], formats: [], version: nil, rights_list: [], descriptions: [], geo_locations: []) ⇒ Resource
constructor
Initialies a new Resource.
-
#namespace
Shadows Namespaced::ClassMethods.namespace.
-
#namespace_prefix=(prefix)
Sets the namespace prefix to be used when writing out XML (defaults to nil).
Constructor Details
#initialize(identifier:, creators:, titles:, publisher:, publication_year:, subjects: [], contributors: [], dates: [], language: nil, funding_references: [], resource_type: nil, alternate_identifiers: [], related_identifiers: [], sizes: [], formats: [], version: nil, rights_list: [], descriptions: [], geo_locations: []) ⇒ Resource
Initialies a new Datacite::Mapping::Resource
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/datacite/mapping/resource.rb', line 65 def initialize(identifier:, creators:, titles:, publisher:, publication_year:, subjects: [], contributors: [], dates: [], language: nil, funding_references: [], resource_type: nil, alternate_identifiers: [], related_identifiers: [], sizes: [], formats: [], version: nil, rights_list: [], descriptions: [], geo_locations: []) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize self.identifier = identifier self.creators = creators self.titles = titles self.publisher = publisher self.publication_year = publication_year self.subjects = subjects self.funding_references = funding_references self.contributors = contributors self.dates = dates self.language = language self.resource_type = resource_type self.alternate_identifiers = alternate_identifiers self. = self.sizes = sizes self.formats = formats self.version = version self.rights_list = rights_list self.descriptions = descriptions self.geo_locations = geo_locations end |
Instance Attribute Details
#alternate_identifiers ⇒ Array<AlternateIdentifier>
Returns an identifier or identifiers other than the primary Identifier applied to the resource being registered.
230 |
# File 'lib/datacite/mapping/resource.rb', line 230 array_node :alternate_identifiers, 'alternateIdentifiers', 'alternateIdentifier', class: AlternateIdentifier, default_value: [] |
#contributors ⇒ Array<Contributor>
Returns institutions or persons responsible for collecting, creating, or otherwise contributing to the developement of the dataset.
214 |
# File 'lib/datacite/mapping/resource.rb', line 214 array_node :contributors, 'contributors', 'contributor', class: Contributor, default_value: [] |
#creators ⇒ Array<Creator>
Returns the main researchers involved working on the data, or the authors of the publication in priority order.
186 |
# File 'lib/datacite/mapping/resource.rb', line 186 array_node :creators, 'creators', 'creator', class: Creator |
#dates ⇒ Array<Date>
Returns different dates relevant to the work.
218 |
# File 'lib/datacite/mapping/resource.rb', line 218 array_node :dates, 'dates', 'date', class: Date, default_value: [] |
#descriptions ⇒ Array<Description>
Returns all additional information that does not fit in any of the other categories.
254 |
# File 'lib/datacite/mapping/resource.rb', line 254 empty_filtering_array_node :descriptions, 'descriptions', 'description', class: Description, default_value: [] |
#formats ⇒ Array<String>
Returns technical format of the resource, e.g. file extension or MIME type.
242 |
# File 'lib/datacite/mapping/resource.rb', line 242 array_node :formats, 'formats', 'format', class: String, default_value: [] |
#fundingReferences ⇒ Array<FundingReference>
Returns information about financial support (funding) for the resource being registered.
210 |
# File 'lib/datacite/mapping/resource.rb', line 210 array_node :funding_references, 'fundingReferences', 'fundingReference', class: FundingReference, default_value: [] |
#geo_locations ⇒ Array<GeoLocations>
Returns spatial region or named place where the data was gathered or about which the data is focused.
258 |
# File 'lib/datacite/mapping/resource.rb', line 258 array_node :geo_locations, 'geoLocations', 'geoLocation', class: GeoLocation, default_value: [] |
#identifier ⇒ Identifier
Returns a persistent identifier that identifies a resource.
182 |
# File 'lib/datacite/mapping/resource.rb', line 182 identifier_node :identifier, 'identifier', class: Identifier |
#language ⇒ String
Returns Primary language of the resource: an IETF BCP 47, ISO 639-1 language code.
222 |
# File 'lib/datacite/mapping/resource.rb', line 222 text_node :language, 'language', default_value: nil |
#publication_year ⇒ Integer
Returns year when the resource is made publicly available.
202 |
# File 'lib/datacite/mapping/resource.rb', line 202 numeric_node :publication_year, 'publicationYear' |
#publisher ⇒ Publisher
Returns the name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource.
194 |
# File 'lib/datacite/mapping/resource.rb', line 194 object_node :publisher, 'publisher', class: Publisher |
#related_identifiers ⇒ Array<RelatedIdentifier>
Returns identifiers of related resources.
234 |
# File 'lib/datacite/mapping/resource.rb', line 234 array_node :related_identifiers, 'relatedIdentifiers', 'relatedIdentifier', class: RelatedIdentifier, default_value: [] |
#resource_type ⇒ ResourceType?
Returns the type of the resource. Optional.
198 |
# File 'lib/datacite/mapping/resource.rb', line 198 object_node :resource_type, 'resourceType', class: ResourceType, default_value: nil |
#rights_list ⇒ Array<Rights>
Returns rights information for this resource.
250 |
# File 'lib/datacite/mapping/resource.rb', line 250 array_node :rights_list, 'rightsList', 'rights', class: Rights, default_value: [] |
#sizes ⇒ Array<String>
Returns unstructured size information about the resource.
238 |
# File 'lib/datacite/mapping/resource.rb', line 238 array_node :sizes, 'sizes', 'size', class: String, default_value: [] |
#subjects ⇒ Array<Subject>
Returns subjects, keywords, classification codes, or key phrases describing the resource.
206 |
# File 'lib/datacite/mapping/resource.rb', line 206 empty_filtering_array_node :subjects, 'subjects', 'subject', class: Subject, default_value: [] |
#titles ⇒ Array<Title>
Returns the names or titles by which a resource is known.
190 |
# File 'lib/datacite/mapping/resource.rb', line 190 array_node :titles, 'titles', 'title', class: Title |
#version ⇒ String
Returns version number of the resource. Optional.
246 |
# File 'lib/datacite/mapping/resource.rb', line 246 text_node :version, 'version', default_value: nil |
Instance Method Details
#creator_affiliations ⇒ Array[Array[String]]
Convenience method to get the creators' affiliations. (Bear in mind that each creator can have multiple affiliations.)
269 270 271 |
# File 'lib/datacite/mapping/resource.rb', line 269 def creator_affiliations creators.map(&:affiliation_names) end |
#creator_names ⇒ [Array[String]] An array of the creators' names.
Convenience method to get the creators' names.
262 263 264 |
# File 'lib/datacite/mapping/resource.rb', line 262 def creator_names creators.map { |c| c&.creator_name&.value } end |
#fill_into_xml(xml, options = { mapping: :_default })
Overrides Namespaced::InstanceMethods.fill_into_xml to check mapping
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/datacite/mapping/resource.rb', line 32 def fill_into_xml(xml, = { mapping: :_default }) current_namespace = namespace return super if [:mapping] != :datacite_3 || current_namespace.uri == DATACITE_3_NAMESPACE.uri begin @namespace = DATACITE_3_NAMESPACE.with_prefix(current_namespace.prefix) super ensure @namespace = current_namespace end end |
#funder_contrib ⇒ Contributor?
Convenience method to get the funding contributor.
275 276 277 |
# File 'lib/datacite/mapping/resource.rb', line 275 def funder_contrib contributors.find { |c| c.type == ContributorType::FUNDER } end |
#funder_id ⇒ NameIdentifier?
Convenience method to get the funding contributor identifier.
288 289 290 |
# File 'lib/datacite/mapping/resource.rb', line 288 def funder_id funder_contrib&.identifier end |
#funder_id_value ⇒ String?
Convenience method to get the funding contributor identifier as a string.
294 295 296 |
# File 'lib/datacite/mapping/resource.rb', line 294 def funder_id_value funder_id&.value end |
#funder_name ⇒ String?
contributor type 'funder' is deprecated. Use FundingReference instead.
Convenience method to get the name of the funding contributor.
282 283 284 |
# File 'lib/datacite/mapping/resource.rb', line 282 def funder_name funder_contrib&.name end |
#funding_references=(value)
143 144 145 |
# File 'lib/datacite/mapping/resource.rb', line 143 def funding_references=(value) @funding_references = value || [] end |
#namespace
Shadows Namespaced::ClassMethods.namespace
27 28 29 |
# File 'lib/datacite/mapping/resource.rb', line 27 def namespace @namespace ||= DATACITE_4_NAMESPACE end |
#namespace_prefix=(prefix)
Sets the namespace prefix to be used when writing out XML (defaults to nil)
90 91 92 93 |
# File 'lib/datacite/mapping/resource.rb', line 90 def namespace_prefix=(prefix) old_namespace = namespace @namespace = ::XML::MappingExtensions::Namespace.new(uri: old_namespace.uri, schema_location: old_namespace.schema_location, prefix: prefix) end |