Class: Theoj::Author

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

Constant Summary collapse

AUTHOR_FOOTNOTE_REGEX =
/^[^\^]*/

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#affiliationObject

Returns the value of attribute affiliation.



7
8
9
# File 'lib/theoj/author.rb', line 7

def affiliation
  @affiliation
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#orcidObject

Returns the value of attribute orcid.



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

def orcid
  @orcid
end

Instance Method Details

#given_nameObject



19
20
21
# File 'lib/theoj/author.rb', line 19

def given_name
  @parsed_name.first
end

#initialsObject



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_nameObject



27
28
29
# File 'lib/theoj/author.rb', line 27

def last_name
  @parsed_name.last
end

#middle_nameObject



23
24
25
# File 'lib/theoj/author.rb', line 23

def middle_name
  @parsed_name.middle
end

#to_hObject



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