Module: FilmOn::Services

Included in:
Base
Defined in:
lib/film_on/services.rb

Instance Method Summary collapse

Instance Method Details

#channel(id, opts = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/film_on/services.rb', line 5

def channel(id, opts={})
  return @channel[id] if @channel[id]
  json = get("channel/#{id}")
  if opts[:json]
    @channel[id] = json
    return json
  end
  hash = JSON.parse(json)
  @channel[id] = FilmOn::Channel.new(hash)
end

#channels(opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/film_on/services.rb', line 16

def channels(opts={})
  return @channels if @channels
  json = get("channels")
  if opts[:json]
    @channels = json
    return json
  end
  hash = JSON.parse(json)
  @channels = hash.map{|ch| FilmOn::Channel.new(ch)}
end

#groups(opts = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/film_on/services.rb', line 27

def groups(opts={})
  return @groups if @groups
  json = get("groups")
  if opts[:json]
    @groups = json
    return json
  end
  hash = JSON.parse(json)
  @groups = hash.map{|gr| FilmOn::Group.new(gr)}
end