Class: Hooloo::Genre

Inherits:
MozartHash show all
Defined in:
lib/hooloo/genre.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MozartHash

bool, cast, date, field_mapping, float, #inspect, #method_missing, #respond_to?, uri

Constructor Details

#initialize(obj) ⇒ Genre

Returns a new instance of Genre.



2
3
4
5
6
7
8
9
# File 'lib/hooloo/genre.rb', line 2

def initialize(obj)
  super
  if obj.is_a? String
    @obj = {'canonical_name' => obj}
  else
    @obj = obj
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hooloo::MozartHash

Class Method Details

.list(args = {}) ⇒ Array<Hooloo::Genre>

List all genres known to Hulu

Parameters:

  • args (Hash) (defaults to: {})

    (see Hooloo#request)

Returns:



24
25
26
27
28
# File 'lib/hooloo/genre.rb', line 24

def self.list(args={})
  Hooloo.request("shows/genres")['data'].map do |item|
    Hooloo::Genre.new(item['genre'])
  end
end

Instance Method Details

#shows(args = {}) ⇒ Enumerator<Hooloo::Show>

List all shows in this genre

Parameters:

  • args (Hash) (defaults to: {})

    (see Hooloo#request)

Returns:



14
15
16
17
18
19
# File 'lib/hooloo/genre.rb', line 14

def shows(args={})
  Hooloo.paginated_request('shows', {
    genre: canonical_name,
    sort: 'release_with_popularity'
  }.merge(args), 80) { |g, x| g << Hooloo::Show.new(x['show']) }
end