Sha256: b1b2ee2b111c4141f78752575ff5038bc164f95ec4a26f83d089d5145f4585a2
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
module Arx # Entity/model representing an arXiv paper's author. class Author include HappyMapper include Inspector # The attributes of an arXiv paper's author. ATTRIBUTES = %i[name affiliated? affiliations] tag 'author' # @!method name # The name of the author. # # @return [String] element :name, Cleaner, tag: 'name', parser: :clean # @!method affiliations # The author's affiliations. # # @return [Array<String>] has_many :affiliations, Cleaner, tag: 'affiliation', parser: :clean # Whether or not the author has any affiliations. # # @return [Boolean] def affiliated? !affiliations.empty? end # Serializes the {Author} object into a +Hash+. # # @return [Hash] def to_h Hash[*ATTRIBUTES.map {|_| [_, send(_)]}.flatten(1)] end # Serializes the {Author} object into a valid JSON hash. # # @return [Hash] The resulting JSON hash. def as_json JSON.parse to_json end # Serializes the {Author} object into a valid JSON string. # # @return [String] The resulting JSON string. def to_json to_h.to_json end # Equality check against another author. # # @note This only performs a basic equality check between the authors' names. # @param author [Author] The author to compare against. def ==(author) if author.is_a? Author name == author.name else false end end inspector *ATTRIBUTES end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
arx-1.2.1 | lib/arx/entities/author.rb |
arx-1.2.0 | lib/arx/entities/author.rb |