Class: Theoj::Author
- Inherits:
-
Object
- Object
- Theoj::Author
- Defined in:
- lib/theoj/author.rb
Constant Summary collapse
- AUTHOR_FOOTNOTE_REGEX =
/^[^\^]*/
Instance Attribute Summary collapse
-
#affiliation ⇒ Object
Returns the value of attribute affiliation.
-
#name ⇒ Object
Returns the value of attribute name.
-
#orcid ⇒ Object
Returns the value of attribute orcid.
Instance Method Summary collapse
- #given_name ⇒ Object
-
#initialize(name, orcid, index, affiliations_hash) ⇒ Author
constructor
Initialized with authors & affiliations block in the YAML header from an Open Journal paper e.g.
- #initials ⇒ Object
- #last_name ⇒ Object
- #middle_name ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name, orcid, index, affiliations_hash) ⇒ Author
Initialized with authors & affiliations block in the YAML header from an Open Journal paper e.g. joss.readthedocs.io/en/latest/submitting.html#example-paper-and-bibliography
13 14 15 16 17 |
# File 'lib/theoj/author.rb', line 13 def initialize(name, orcid, index, affiliations_hash) parse_name name @orcid = validate_orcid orcid @affiliation = build_affiliation_string(index, affiliations_hash) end |
Instance Attribute Details
#affiliation ⇒ Object
Returns the value of attribute affiliation.
7 8 9 |
# File 'lib/theoj/author.rb', line 7 def affiliation @affiliation end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/theoj/author.rb', line 5 def name @name end |
#orcid ⇒ Object
Returns the value of attribute orcid.
6 7 8 |
# File 'lib/theoj/author.rb', line 6 def orcid @orcid end |
Instance Method Details
#given_name ⇒ Object
19 20 21 |
# File 'lib/theoj/author.rb', line 19 def given_name @parsed_name.first end |
#initials ⇒ Object
31 32 33 |
# File 'lib/theoj/author.rb', line 31 def initials [@parsed_name.first, @parsed_name.middle].compact.map {|v| v[0] + "."} * ' ' end |
#last_name ⇒ Object
27 28 29 |
# File 'lib/theoj/author.rb', line 27 def last_name @parsed_name.last end |
#middle_name ⇒ Object
23 24 25 |
# File 'lib/theoj/author.rb', line 23 def middle_name @parsed_name.middle end |
#to_h ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/theoj/author.rb', line 35 def to_h { given_name: given_name, middle_name: middle_name, last_name: last_name, orcid: orcid, affiliation: affiliation } end |