Class: Arx::Category
- Inherits:
-
Object
- Object
- Arx::Category
- Includes:
- Inspector, HappyMapper
- Defined in:
- lib/arx/entities/category.rb
Overview
Entity/model representing an arXiv paper’s category.
Constant Summary collapse
- ATTRIBUTES =
The attributes of an arXiv paper’s category.
%i[name full_name]
Instance Method Summary collapse
-
#==(category) ⇒ Boolean
Equality check against another category.
-
#as_json ⇒ Hash
Serializes the Category object into a valid JSON hash.
-
#full_name ⇒ String
The full name of the category.
-
#name ⇒ String
The abbreviated name of the category.
-
#to_h ⇒ Hash
Serializes the Category object into a
Hash
. -
#to_json ⇒ String
Serializes the Category object into a valid JSON string.
-
#to_s ⇒ String
A string representation of the Category object.
Methods included from Inspector
Instance Method Details
#==(category) ⇒ Boolean
Equality check against another category.
52 53 54 55 56 57 58 |
# File 'lib/arx/entities/category.rb', line 52 def ==(category) if category.is_a? Category name == category.name else false end end |
#as_json ⇒ Hash
Serializes the Arx::Category object into a valid JSON hash.
37 38 39 |
# File 'lib/arx/entities/category.rb', line 37 def as_json JSON.parse to_json end |
#full_name ⇒ String
The full name of the category.
23 24 25 |
# File 'lib/arx/entities/category.rb', line 23 def full_name CATEGORIES[name] end |
#name ⇒ String
The abbreviated name of the category.
17 |
# File 'lib/arx/entities/category.rb', line 17 attribute :name, Cleaner, parser: :clean, tag: 'term' |
#to_h ⇒ Hash
Serializes the Arx::Category object into a Hash
.
30 31 32 |
# File 'lib/arx/entities/category.rb', line 30 def to_h Hash[*ATTRIBUTES.map {|_| [_, send(_)]}.flatten(1)] end |
#to_json ⇒ String
Serializes the Arx::Category object into a valid JSON string.
44 45 46 |
# File 'lib/arx/entities/category.rb', line 44 def to_json to_h.to_json end |
#to_s ⇒ String
A string representation of the Arx::Category object.
63 64 65 |
# File 'lib/arx/entities/category.rb', line 63 def to_s "Arx::Category(name: #{name}, full_name: #{full_name || 'nil'})" end |