Class: Mangadex::Relationship
- Inherits:
-
MangadexObject
- Object
- MangadexObject
- Mangadex::Relationship
- Defined in:
- lib/mangadex/relationship.rb
Constant Summary collapse
- RELATED_VALUES =
%w( monochrome main_story adapted_from based_on prequel side_story doujinshi same_franchise shared_universe sequel spin_off alternate_story preserialization colored serialization ).freeze
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#id ⇒ Object
Returns the value of attribute id.
-
#related ⇒ Object
Returns the value of attribute related.
-
#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
#eq?, #hash, #initialize, #inspect
Constructor Details
This class inherits a constructor from Mangadex::MangadexObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(value) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/mangadex/relationship.rb', line 59 def method_missing(value) return super unless value.end_with?("?") = value.to_s.split("?").first return super unless RELATED_VALUES.include?() !.nil? && == end |
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 |
#related ⇒ Object
Returns the value of attribute related.
4 5 6 |
# File 'lib/mangadex/relationship.rb', line 4 def 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
.attributes_to_inspect ⇒ Object
54 55 56 |
# File 'lib/mangadex/relationship.rb', line 54 def self.attributes_to_inspect [:id, :type, :related] end |
.from_data(data) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mangadex/relationship.rb', line 25 def from_data(data) data = data.with_indifferent_access klass = class_for_relationship_type(data['type']) if klass && data['attributes']&.any? return klass.from_data(data, related_type: data['related']) end new( id: data['id'], type: data['type'], attributes: OpenStruct.new(data['attributes']), related: data['related'], ) end |