Class: Dina::Identifier
- Inherits:
-
BaseModel
- Object
- JsonApiClient::Resource
- BaseModel
- Dina::Identifier
show all
- Defined in:
- lib/dina/utils/identifier.rb,
lib/dina/models/agent/identifier.rb
Class Method Summary
collapse
Methods inherited from BaseModel
custom_headers, #english_description, find_by_group, #french_description, #initialize, site
Class Method Details
.endpoint_path ⇒ Object
13
14
15
|
# File 'lib/dina/models/agent/identifier.rb', line 13
def self.endpoint_path
"agent-api/"
end
|
51
52
53
|
# File 'lib/dina/utils/identifier.rb', line 51
def
/(?<=orcid\.org\/)(\d{4}-){3}\d{3}[0-9X]{1}/
end
|
55
56
57
|
# File 'lib/dina/utils/identifier.rb', line 55
def
/(?:wikidata\.org\/(entity|wiki)\/)\K(Q[0-9]{1,})/
end
|
.is_doi_regex ⇒ Object
38
39
40
|
# File 'lib/dina/utils/identifier.rb', line 38
def is_doi_regex
/^10.\d{4,9}\/[-._;()\/:<>A-Z0-9]+$/i
end
|
.is_orcid_regex ⇒ Object
30
31
32
|
# File 'lib/dina/utils/identifier.rb', line 30
def is_orcid_regex
/^0000-000(1-[5-9]|2-[0-9]|3-[0-4])\d{3}-\d{3}[\dX]$/
end
|
.is_wiki_regex ⇒ Object
34
35
36
|
# File 'lib/dina/utils/identifier.rb', line 34
def is_wiki_regex
/^Q[0-9]{1,}$/
end
|
.orcid_valid_checksum(orcid_string) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/dina/utils/identifier.rb', line 42
def orcid_valid_checksum(orcid_string)
parts = orcid_string.scan(/[0-9X]/)
mod = parts[0..14].map(&:to_i)
.inject { |sum, n| (sum + n)*2 }
.modulo(11)
result = (12 - mod) % 11
parts.last == ((result == 10) ? "X" : result.to_s)
end
|
.table_name ⇒ Object
17
18
19
|
# File 'lib/dina/models/agent/identifier.rb', line 17
def self.table_name
"identifier"
end
|