Class: Shin::Play::Tv2sumo

Inherits:
Object
  • Object
show all
Defined in:
lib/shin/play/tv2sumo.rb

Defined Under Namespace

Classes: HTTPError, MissingArgument, NotValid

Instance Method Summary collapse

Instance Method Details

#juniorObject

All children shows

Raises:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/shin/play/tv2sumo.rb', line 45

def junior
  # Response
  response = Base.get('https://sumo.tv2.no/rest/categories/91101/shows?sort=alphabetical&size=999')
  raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200

  # Data
  data = Oj.load(response.body) rescue nil

  # Can't be nil
  if data != nil
    data['shows'].to_hashugar
  else
    raise NotValid, "Couldn't parse the JSON"
  end
end

#moviesObject

All movies

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/shin/play/tv2sumo.rb', line 28

def movies
  # Response
  response = Base.get('https://sumo.tv2.no/rest/categories/90987/movies?sort=alphabetical&size=999')
  raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200

  # Data
  data = Oj.load(response.body) rescue nil

  # Can't be nil
  if data != nil
    data['assets'].to_hashugar
  else
    raise NotValid, "Couldn't parse the JSON"
  end
end

#newObject



6
7
8
# File 'lib/shin/play/tv2sumo.rb', line 6

def new
  self
end

#seriesObject

All tv series

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/shin/play/tv2sumo.rb', line 11

def series
  # Response
  response = Base.get('https://sumo.tv2.no/rest/categories/90316/shows?sort=alphabetical&size=999')
  raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200

  # Data
  data = Oj.load(response.body) rescue nil

  # Can't be nil
  if data != nil
    data['shows'].to_hashugar
  else
    raise NotValid, "Couldn't parse the JSON"
  end
end