class Shin::Data::Dfi

Public Instance Methods

info(params={}) click to toggle source

Info

# File lib/shin/data/dfi.rb, line 53
def info(params={})
  raise MissingArgument, "You are missing the argument 'id' which is required to use this source." unless params[:id] != ""
  
  # Response
  response = Base.get('http://nationalfilmografien.service.dfi.dk/movie.svc/' + params[:id].to_s)
  raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
  
  # Nokogiri parse
  data = response.parsed_response['MovieItem'] rescue nil
  
  if data != nil
    {id: data['ID'].to_i, title: data['Title'], original_title: data['OriginalTitle'].strip, age_limit: data['Censorship'], url: data['Url'], description: data['Description']}.to_hashugar
  else
    raise NotValid, "Nokogiri failed to parse the XML."
  end
end
new() click to toggle source
# File lib/shin/data/dfi.rb, line 8
def new
  self
end