Class: Zimdb::Movie
- Inherits:
-
Object
- Object
- Zimdb::Movie
- Defined in:
- lib/zimdb/movie.rb
Instance Method Summary collapse
- #actors ⇒ Object
- #director ⇒ Object
- #genre ⇒ Object
- #get_movie(param, val) ⇒ Object
- #imdb_id ⇒ Object
-
#initialize(params) ⇒ Movie
constructor
A new instance of Movie.
- #plot ⇒ Object
- #poster ⇒ Object
- #rated ⇒ Object
- #rating ⇒ Object
- #released ⇒ Object
- #response ⇒ Object
- #runtime ⇒ Object
- #title ⇒ Object
- #votes ⇒ Object
- #writer ⇒ Object
- #year ⇒ Object
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
#actors ⇒ Object
44 45 46 |
# File 'lib/zimdb/movie.rb', line 44 def actors @json[:actors] end |
#director ⇒ Object
36 37 38 |
# File 'lib/zimdb/movie.rb', line 36 def director @json[:director] end |
#genre ⇒ Object
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_id ⇒ Object
68 69 70 |
# File 'lib/zimdb/movie.rb', line 68 def imdb_id @json[:id] end |
#plot ⇒ Object
48 49 50 |
# File 'lib/zimdb/movie.rb', line 48 def plot @json[:plot] end |
#poster ⇒ Object
52 53 54 |
# File 'lib/zimdb/movie.rb', line 52 def poster @json[:poster] end |
#rated ⇒ Object
24 25 26 |
# File 'lib/zimdb/movie.rb', line 24 def rated @json[:rated] end |
#rating ⇒ Object
60 61 62 |
# File 'lib/zimdb/movie.rb', line 60 def @json[:rating].to_f end |
#released ⇒ Object
28 29 30 |
# File 'lib/zimdb/movie.rb', line 28 def released @json[:released] end |
#response ⇒ Object
12 13 14 |
# File 'lib/zimdb/movie.rb', line 12 def response @json[:response] == "True" ? true : false end |
#runtime ⇒ Object
56 57 58 |
# File 'lib/zimdb/movie.rb', line 56 def runtime @json[:runtime] end |
#title ⇒ Object
20 21 22 |
# File 'lib/zimdb/movie.rb', line 20 def title @json[:title] end |
#votes ⇒ Object
64 65 66 |
# File 'lib/zimdb/movie.rb', line 64 def votes @json[:votes].to_i end |
#writer ⇒ Object
40 41 42 |
# File 'lib/zimdb/movie.rb', line 40 def writer @json[:writer] end |
#year ⇒ Object
16 17 18 |
# File 'lib/zimdb/movie.rb', line 16 def year @json[:year].to_i end |