Module: OrcidClient::Author
- Included in:
- Notification, Work
- Defined in:
- lib/orcid_client/author.rb
Instance Method Summary collapse
-
#get_authors(authors) ⇒ Object
parse array of author strings into CSL format.
- #get_credit_name(author) ⇒ Object
- #get_full_name(author) ⇒ Object
-
#get_hashed_authors(authors) ⇒ Object
parse array of author hashes into CSL format.
- #get_name_identifier(author) ⇒ Object
-
#get_one_author(author) ⇒ Object
parse author string into CSL format.
- #get_one_hashed_author(author) ⇒ Object
Instance Method Details
#get_authors(authors) ⇒ Object
parse array of author strings into CSL format
21 22 23 |
# File 'lib/orcid_client/author.rb', line 21 def () Array().map { || () } end |
#get_credit_name(author) ⇒ Object
48 49 50 |
# File 'lib/orcid_client/author.rb', line 48 def get_credit_name() [['given'], ['family']].compact.join(' ').presence || ['literal'] end |
#get_full_name(author) ⇒ Object
52 53 54 |
# File 'lib/orcid_client/author.rb', line 52 def get_full_name() [['family'], ['given']].compact.join(', ') end |
#get_hashed_authors(authors) ⇒ Object
parse array of author hashes into CSL format
26 27 28 |
# File 'lib/orcid_client/author.rb', line 26 def () Array().map { || () } end |
#get_name_identifier(author) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/orcid_client/author.rb', line 38 def get_name_identifier() name_identifier = .fetch("nameIdentifier", nil) name_identifier_scheme = .fetch("nameIdentifierScheme", "orcid").downcase if name_identifier.present? && name_identifier_scheme == "orcid" "http://orcid.org/#{name_identifier}" else nil end end |
#get_one_author(author) ⇒ Object
parse author string into CSL format
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/orcid_client/author.rb', line 6 def () return "" if .blank? names = Namae.parse() if names.present? name = names.first { "family" => name.family, "given" => name.given }.compact else { "literal" => } end end |
#get_one_hashed_author(author) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/orcid_client/author.rb', line 30 def () raw_name = .fetch("creatorName", nil) = (raw_name) ["ORCID"] = get_name_identifier() .compact end |