Class: Zimdb::Movie

Inherits:
Object
  • Object
show all
Defined in:
lib/zimdb/movie.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Movie

Returns a new instance of Movie.



4
5
6
# File 'lib/zimdb/movie.rb', line 4

def initialize(params)
  @json = params[:id].nil? ? get_movie("t", URI::encode(params[:title])) : get_movie("i", params[:id])
end

Instance Method Details

#actorsObject



44
45
46
# File 'lib/zimdb/movie.rb', line 44

def actors
  @json[:actors]
end

#directorObject



36
37
38
# File 'lib/zimdb/movie.rb', line 36

def director
  @json[:director]
end

#genreObject



32
33
34
# File 'lib/zimdb/movie.rb', line 32

def genre
  @json[:genre]
end

#get_movie(param, val) ⇒ Object



8
9
10
# File 'lib/zimdb/movie.rb', line 8

def get_movie(param, val)
  JSON.parse(HTTParty.get("http://www.imdbapi.com/?#{param}=#{val}")).symbolize_keys
end

#imdb_idObject



68
69
70
# File 'lib/zimdb/movie.rb', line 68

def imdb_id
  @json[:id]
end

#plotObject



48
49
50
# File 'lib/zimdb/movie.rb', line 48

def plot
  @json[:plot]
end

#posterObject



52
53
54
# File 'lib/zimdb/movie.rb', line 52

def poster
  @json[:poster]
end

#ratedObject



24
25
26
# File 'lib/zimdb/movie.rb', line 24

def rated
  @json[:rated]
end

#ratingObject



60
61
62
# File 'lib/zimdb/movie.rb', line 60

def rating
  @json[:rating].to_f
end

#releasedObject



28
29
30
# File 'lib/zimdb/movie.rb', line 28

def released
  @json[:released]
end

#responseObject



12
13
14
# File 'lib/zimdb/movie.rb', line 12

def response
  @json[:response] == "True" ? true : false
end

#runtimeObject



56
57
58
# File 'lib/zimdb/movie.rb', line 56

def runtime
  @json[:runtime]
end

#titleObject



20
21
22
# File 'lib/zimdb/movie.rb', line 20

def title
  @json[:title]
end

#votesObject



64
65
66
# File 'lib/zimdb/movie.rb', line 64

def votes
  @json[:votes].to_i
end

#writerObject



40
41
42
# File 'lib/zimdb/movie.rb', line 40

def writer
  @json[:writer]
end

#yearObject



16
17
18
# File 'lib/zimdb/movie.rb', line 16

def year
  @json[:year].to_i
end