Class: Mangadex::Relationship
- Inherits:
-
MangadexObject
- Object
- MangadexObject
- Mangadex::Relationship
- Defined in:
- lib/mangadex/relationship.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#id ⇒ Object
Returns the value of attribute id.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes included from Internal::WithAttributes
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from MangadexObject
attributes_to_inspect, #eq?, #hash, #initialize
Constructor Details
This class inherits a constructor from Mangadex::MangadexObject
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/mangadex/relationship.rb', line 4 def attributes @attributes end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/mangadex/relationship.rb', line 4 def id @id end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/mangadex/relationship.rb', line 4 def type @type end |
Class Method Details
.from_data(data) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mangadex/relationship.rb', line 7 def from_data(data) data = data.with_indifferent_access klass = class_for_relationship_type(data['type']) return klass.from_data(data) if klass && data['attributes']&.any? new( id: data['id'], type: data['type'], attributes: OpenStruct.new(data['attributes']), ) end |
Instance Method Details
#inspect ⇒ Object
42 43 44 |
# File 'lib/mangadex/relationship.rb', line 42 def inspect "#<#{self.class} id=#{id.inspect} type=#{type.inspect}>" end |