Class: Arx::Author
- Inherits:
-
Object
- Object
- Arx::Author
- Includes:
- Inspector, HappyMapper
- Defined in:
- lib/arx/entities/author.rb
Overview
Entity/model representing an arXiv paper’s author.
Constant Summary collapse
- ATTRIBUTES =
The attributes of an arXiv paper’s author.
%i[name affiliated? affiliations]
Instance Method Summary collapse
-
#==(author) ⇒ Boolean
Equality check against another author.
-
#affiliated? ⇒ Boolean
Whether or not the author has any affiliations.
-
#affiliations ⇒ Array<String>
The author’s affiliations.
-
#as_json ⇒ Hash
Serializes the Author object into a valid JSON hash.
-
#name ⇒ String
The name of the author.
-
#to_h ⇒ Hash
Serializes the Author object into a
Hash. -
#to_json ⇒ String
Serializes the Author object into a valid JSON string.
-
#to_s ⇒ String
A string representation of the Author object.
Methods included from Inspector
Instance Method Details
#==(author) ⇒ Boolean
This only performs a basic equality check between the authors’ names.
Equality check against another author.
58 59 60 61 62 63 64 |
# File 'lib/arx/entities/author.rb', line 58 def ==() if .is_a? Author name == .name else false end end |
#affiliated? ⇒ Boolean
Whether or not the author has any affiliations.
28 29 30 |
# File 'lib/arx/entities/author.rb', line 28 def affiliated? !affiliations.empty? end |
#affiliations ⇒ Array<String>
The author’s affiliations.
23 |
# File 'lib/arx/entities/author.rb', line 23 has_many :affiliations, Cleaner, tag: 'affiliation', parser: :clean |
#as_json ⇒ Hash
Serializes the Arx::Author object into a valid JSON hash.
42 43 44 |
# File 'lib/arx/entities/author.rb', line 42 def as_json JSON.parse to_json end |
#name ⇒ String
The name of the author.
17 |
# File 'lib/arx/entities/author.rb', line 17 element :name, Cleaner, tag: 'name', parser: :clean |
#to_h ⇒ Hash
Serializes the Arx::Author object into a Hash.
35 36 37 |
# File 'lib/arx/entities/author.rb', line 35 def to_h Hash[*ATTRIBUTES.map {|_| [_, send(_)]}.flatten(1)] end |
#to_json ⇒ String
Serializes the Arx::Author object into a valid JSON string.
49 50 51 |
# File 'lib/arx/entities/author.rb', line 49 def to_json to_h.to_json end |
#to_s ⇒ String
A string representation of the Arx::Author object.
69 70 71 |
# File 'lib/arx/entities/author.rb', line 69 def to_s "Arx::Author(name: #{name}, affiliations: [#{affiliations.join(', ')}])" end |