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, #inspect, #method_missing, #respond_to?

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:



18
19
20
21
22
# File 'lib/hooloo/genre.rb', line 18

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

Instance Method Details

#shows(args = {items_per_page: 10, position: 0}) ⇒ Object



10
11
12
13
# File 'lib/hooloo/genre.rb', line 10

def shows(args={items_per_page: 10, position: 0})
  args.merge!({genre: canonical_name})
  Hooloo.request('shows', args)['data'].map { |x| Hooloo::Show.new x['show'] }
end