Class: ImdbParty::Movie
- Inherits:
-
Object
- Object
- ImdbParty::Movie
- Defined in:
- lib/imdb_party/movie.rb
Instance Attribute Summary collapse
-
#actors ⇒ Object
Returns the value of attribute actors.
-
#certification ⇒ Object
Returns the value of attribute certification.
-
#company ⇒ Object
Returns the value of attribute company.
-
#directors ⇒ Object
Returns the value of attribute directors.
-
#genres ⇒ Object
Returns the value of attribute genres.
-
#imdb_id ⇒ Object
Returns the value of attribute imdb_id.
-
#plot ⇒ Object
Returns the value of attribute plot.
-
#poster_url ⇒ Object
Returns the value of attribute poster_url.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#release_date ⇒ Object
Returns the value of attribute release_date.
-
#runtime ⇒ Object
Returns the value of attribute runtime.
-
#tagline ⇒ Object
Returns the value of attribute tagline.
-
#title ⇒ Object
Returns the value of attribute title.
-
#trailers ⇒ Object
Returns the value of attribute trailers.
-
#writers ⇒ Object
Returns the value of attribute writers.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Movie
constructor
A new instance of Movie.
Constructor Details
#initialize(options = {}) ⇒ Movie
Returns a new instance of Movie.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/imdb_party/movie.rb', line 5 def initialize(={}) if not .nil? and .keys.first.class == Symbol .keys.each { |name| instance_variable_set "@" + name.to_s, [name] }; return end @imdb_id = ["tconst"] @title = ["title"] @tagline = ["tagline"] @plot = ["plot"]["outline"] if ["plot"] @runtime = "#{(options["runtime"]["time"]/60).to_i} min" if ["runtime"] = ["rating"] @poster_url = ["image"]["url"] if ["image"] @release_date = ["release_date"]["normal"] if ["release_date"] && ["release_date"]["normal"] @certification = ["certificate"]["certificate"] if ["certificate"] && ["certificate"]["certificate"] @genres = ["genres"] || [] # Sometimes the @release_date object is a string instead of a date object if @release_date.class == String [{:regex => /^\d{4}-\d{2}$/, :concat => "-01"}, {:regex => /^\d{4}$/, :concat => "-01-01"}].each do |value| if @release_date.match(value[:regex]) @release_date = Date.parse(@release_date << value[:concat]); break end end end # parse directors @directors = ["directors_summary"] ? ["directors_summary"].map { |d| Person.new(d) } : [] # parse directors @writers = [] @writers = ["writers_summary"] ? ["writers_summary"].map { |w| Person.new(w) } : [] # parse actors @actors = [] @actors = ["cast_summary"] ? ["cast_summary"].map { |a| Person.new(a) } : [] #parse trailers @trailers = {} if ["trailer"] && ["trailer"]["encodings"] ["trailer"]["encodings"].each_pair do |k,v| @trailers[v["format"]] = v["url"] end end end |
Instance Attribute Details
#actors ⇒ Object
Returns the value of attribute actors.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def actors @actors end |
#certification ⇒ Object
Returns the value of attribute certification.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def certification @certification end |
#company ⇒ Object
Returns the value of attribute company.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def company @company end |
#directors ⇒ Object
Returns the value of attribute directors.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def directors @directors end |
#genres ⇒ Object
Returns the value of attribute genres.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def genres @genres end |
#imdb_id ⇒ Object
Returns the value of attribute imdb_id.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def imdb_id @imdb_id end |
#plot ⇒ Object
Returns the value of attribute plot.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def plot @plot end |
#poster_url ⇒ Object
Returns the value of attribute poster_url.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def poster_url @poster_url end |
#rating ⇒ Object
Returns the value of attribute rating.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def end |
#release_date ⇒ Object
Returns the value of attribute release_date.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def release_date @release_date end |
#runtime ⇒ Object
Returns the value of attribute runtime.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def runtime @runtime end |
#tagline ⇒ Object
Returns the value of attribute tagline.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def tagline @tagline end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def title @title end |
#trailers ⇒ Object
Returns the value of attribute trailers.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def trailers @trailers end |
#writers ⇒ Object
Returns the value of attribute writers.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def writers @writers end |
#year ⇒ Object
Returns the value of attribute year.
3 4 5 |
# File 'lib/imdb_party/movie.rb', line 3 def year @year end |