Class: PDCMetadata::NameIdentifier
- Inherits:
-
Object
- Object
- PDCMetadata::NameIdentifier
- Defined in:
- app/models/pdc_metadata/name_identifier.rb
Overview
value: “0000-0001-5000-0007” scheme: “ORCID” scheme_uri: “orcid.org/”“
Constant Summary collapse
- ORCID =
"ORCID"
- ROR =
"ROR"
Instance Attribute Summary collapse
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#scheme_uri ⇒ Object
Returns the value of attribute scheme_uri.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value: nil, scheme: nil, scheme_uri: nil) ⇒ NameIdentifier
constructor
A new instance of NameIdentifier.
- #orcid ⇒ Object
- #orcid_url ⇒ Object
- #ror ⇒ Object
- #ror_id ⇒ Object
-
#ror_url ⇒ Object
Allow override of where to look up ROR values.
Constructor Details
#initialize(value: nil, scheme: nil, scheme_uri: nil) ⇒ NameIdentifier
Returns a new instance of NameIdentifier.
12 13 14 15 16 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 12 def initialize(value: nil, scheme: nil, scheme_uri: nil) @value = value @scheme = scheme @scheme_uri = scheme_uri end |
Instance Attribute Details
#scheme ⇒ Object
Returns the value of attribute scheme.
11 12 13 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 11 def scheme @scheme end |
#scheme_uri ⇒ Object
Returns the value of attribute scheme_uri.
11 12 13 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 11 def scheme_uri @scheme_uri end |
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 11 def value @value end |
Class Method Details
.new_orcid(value) ⇒ Object
49 50 51 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 49 def self.new_orcid(value) NameIdentifier.new(value:, scheme: ORCID, scheme_uri: "https://orcid.org") end |
.new_ror(value) ⇒ Object
53 54 55 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 53 def self.new_ror(value) NameIdentifier.new(value:, scheme: ROR, scheme_uri: "https://ror.org") end |
Instance Method Details
#orcid ⇒ Object
26 27 28 29 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 26 def orcid return nil unless scheme == ORCID value end |
#orcid_url ⇒ Object
21 22 23 24 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 21 def orcid_url return nil unless scheme == ORCID "#{scheme_uri}/#{value}" end |
#ror ⇒ Object
31 32 33 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 31 def ror ror_url end |
#ror_id ⇒ Object
44 45 46 47 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 44 def ror_id return nil unless scheme == ROR value.split("/").last end |
#ror_url ⇒ Object
Allow override of where to look up ROR values. This lets us test ROR behavior without making network calls. See spec/support/orcid_specs.rb for more info
38 39 40 41 42 |
# File 'app/models/pdc_metadata/name_identifier.rb', line 38 def ror_url return nil unless scheme == ROR value end |