Class: Orcid

Inherits:
Object
  • Object
show all
Defined in:
app/models/orcid.rb

Constant Summary collapse

ORCID_REGEX =

Notice that we allow for an “X” as the last digit. Source gist.github.com/asencis/644f174855899b873131c2cabcebeb87

/^(\d{4}-){3}\d{3}(\d|X)$/

Class Method Summary collapse

Class Method Details

.invalid?(orcid) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/orcid.rb', line 14

def self.invalid?(orcid)
  !valid?(orcid)
end

.url(orcid) ⇒ Object



18
19
20
# File 'app/models/orcid.rb', line 18

def self.url(orcid)
  "https://orcid.org/#{orcid}"
end

.valid?(orcid) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'app/models/orcid.rb', line 9

def self.valid?(orcid)
  return false if orcid.blank?
  ORCID_REGEX.match(orcid).to_s == orcid
end