Class: Kitsu::Producer
- Inherits:
-
Object
- Object
- Kitsu::Producer
- Defined in:
- lib/kitsu/producer.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #anime(**filters) ⇒ Object
- #anime_related ⇒ Object
-
#initialize(data) ⇒ Producer
constructor
A new instance of Producer.
- #library_entries ⇒ Object
Constructor Details
#initialize(data) ⇒ Producer
Returns a new instance of Producer.
6 7 8 |
# File 'lib/kitsu/producer.rb', line 6 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/kitsu/producer.rb', line 4 def data @data end |
Class Method Details
Instance Method Details
#anime(**filters) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kitsu/producer.rb', line 12 def anime(**filters) anime = .map do |parsed| Kitsu::Anime.new(parsed) end anime.select do |a| filters.all? do |key, value| a.data['attributes'][key.to_s] == value end end end |
#anime_related ⇒ Object
26 27 28 |
# File 'lib/kitsu/producer.rb', line 26 def library_entries.map(&:related_anime).flatten end |
#library_entries ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/kitsu/producer.rb', line 33 def library_entries parsed = API.get(@data['relationships']['animeProductions']['links']['related']) library_entries = [parsed] loop do parsed = API.get(parsed['links']['next']) library_entries << parsed break unless parsed['links'].key? 'next' end library_entries.flatten.map do |producer| Kitsu::LibraryEntry.new(producer) end end |