Class: Shin::Reviews::Moviezine

Inherits:
Object
  • Object
show all
Defined in:
lib/shin/reviews/moviezine.rb

Defined Under Namespace

Classes: HTTPError, MissingArgument

Instance Method Summary collapse

Instance Method Details

#find(h = {}) ⇒ Object

Currently IMDB ID is the only way

Raises:



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/shin/reviews/moviezine.rb', line 14

def find(h = {})
  raise MissingArgument, "You are missing the argument 'imdb' which is required to use this source." unless h[:imdb] != ""
  
  # We got the needed things
  imdb_id_int = h[:imdb].gsub(/^tt/, "")
  response = Base.get('https://www.film2home.se/Services/MovieZine.svc/GetReview?imdbId='+imdb_id_int.to_s)
  
  # Raise error if it didn't have a correct http code.
  raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
  
  data = response.parsed_response
  {name: nil, year: nil, title: data['Title'], rating: data['Rating'].to_i, url: data['Url'], votes: nil}.to_hashugar
end

#newObject



9
10
11
# File 'lib/shin/reviews/moviezine.rb', line 9

def new
  self
end