Class: PDCMetadata::NameIdentifier

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#schemeObject

Returns the value of attribute scheme.



11
12
13
# File 'app/models/pdc_metadata/name_identifier.rb', line 11

def scheme
  @scheme
end

#scheme_uriObject

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

#valueObject

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

#orcidObject



26
27
28
29
# File 'app/models/pdc_metadata/name_identifier.rb', line 26

def orcid
  return nil unless scheme == ORCID
  value
end

#orcid_urlObject



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

#rorObject



31
32
33
# File 'app/models/pdc_metadata/name_identifier.rb', line 31

def ror
  ror_url
end

#ror_idObject



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_urlObject

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