Class: Theoj::Orcid

Inherits:
Object
  • Object
show all
Defined in:
lib/theoj/orcid.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(orcid) ⇒ Orcid

Returns a new instance of Orcid.



5
6
7
8
# File 'lib/theoj/orcid.rb', line 5

def initialize(orcid)
  @orcid = orcid.strip
  @error = nil
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



3
4
5
# File 'lib/theoj/orcid.rb', line 3

def error
  @error
end

#orcidObject (readonly)

Returns the value of attribute orcid.



3
4
5
# File 'lib/theoj/orcid.rb', line 3

def orcid
  @orcid
end

Instance Method Details

#packed_orcidObject



21
22
23
# File 'lib/theoj/orcid.rb', line 21

def packed_orcid
  orcid.gsub('-', '')
end

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
# File 'lib/theoj/orcid.rb', line 10

def valid?
  @error = nil
  return false unless check_structure
  return false unless check_length
  return false unless check_chars

  return false unless correct_checksum?

  true
end