Class: Allocine::AllocineBase
- Inherits:
-
Object
- Object
- Allocine::AllocineBase
- Defined in:
- lib/allocine/allocine_base.rb
Overview
Represents a AllocineBase
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#title(force_refresh = false) ⇒ Object
Returns a string containing the title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#actors ⇒ Object
Returns an array with cast members.
-
#countries ⇒ Object
Returns an array of countries as strings.
-
#directors ⇒ Object
Returns the name of the director.
-
#genres ⇒ Object
Returns an array of genres (as strings).
-
#initialize(allocine_id, title = nil) ⇒ AllocineBase
constructor
A new instance of AllocineBase.
-
#length ⇒ Object
Returns the duration of the movie in minutes as an integer.
-
#original_title ⇒ Object
Returns originalTitle.
- #plot(short = true) ⇒ Object
-
#poster ⇒ Object
Returns a string containing the URL to the movie poster.
-
#press_rating ⇒ Object
Returns a float containing the average user rating.
-
#production_year ⇒ Object
Return production Year for the movie.
-
#release_date ⇒ Object
Returns release date for the movie.
-
#trailer ⇒ Object
Returns a string containing the URL to the movie trailer.
-
#trailer_id ⇒ Object
Returns a string containing trailer code.
-
#user_rating ⇒ Object
Returns an int containing the number of user ratings.
Constructor Details
#initialize(allocine_id, title = nil) ⇒ AllocineBase
Returns a new instance of AllocineBase.
11 12 13 14 |
# File 'lib/allocine/allocine_base.rb', line 11 def initialize(allocine_id, title = nil) @id = allocine_id @url = "http://api.allocine.fr/rest/v3/movie?code=#{allocine_id}&profile=large&format=json&partner=YW5kcm9pZC12M3M" end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/allocine/allocine_base.rb', line 9 def id @id end |
#title(force_refresh = false) ⇒ Object
Returns a string containing the title
67 68 69 |
# File 'lib/allocine/allocine_base.rb', line 67 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/allocine/allocine_base.rb', line 9 def url @url end |
Instance Method Details
#actors ⇒ Object
Returns an array with cast members
22 23 24 |
# File 'lib/allocine/allocine_base.rb', line 22 def actors document["castingShort"]["actors"].split(", ") rescue nil end |
#countries ⇒ Object
Returns an array of countries as strings.
32 33 34 |
# File 'lib/allocine/allocine_base.rb', line 32 def countries document["nationality"].collect {|nation| nation["$"]} rescue nil end |
#directors ⇒ Object
Returns the name of the director
17 18 19 |
# File 'lib/allocine/allocine_base.rb', line 17 def directors document["castingShort"]["directors"].split(", ") rescue nil end |
#genres ⇒ Object
Returns an array of genres (as strings)
27 28 29 |
# File 'lib/allocine/allocine_base.rb', line 27 def genres document["genre"].collect {|gender| gender["$"]} rescue nil end |
#length ⇒ Object
Returns the duration of the movie in minutes as an integer.
37 38 39 |
# File 'lib/allocine/allocine_base.rb', line 37 def length document["runtime"].to_i/60 rescue nil end |
#original_title ⇒ Object
Returns originalTitle.
76 77 78 |
# File 'lib/allocine/allocine_base.rb', line 76 def original_title document["originalTitle"] rescue nil end |
#plot(short = true) ⇒ Object
91 92 93 |
# File 'lib/allocine/allocine_base.rb', line 91 def plot(short = true) short ? document["synopsisShort"] : document["synopsis"] end |
#poster ⇒ Object
Returns a string containing the URL to the movie poster.
42 43 44 |
# File 'lib/allocine/allocine_base.rb', line 42 def poster document["poster"]["href"] rescue nil end |
#press_rating ⇒ Object
Returns a float containing the average user rating
57 58 59 |
# File 'lib/allocine/allocine_base.rb', line 57 def document["statistics"]["pressRating"] rescue nil end |
#production_year ⇒ Object
Return production Year for the movie
87 88 89 |
# File 'lib/allocine/allocine_base.rb', line 87 def production_year document["productionYear"] end |
#release_date ⇒ Object
Returns release date for the movie.
82 83 84 |
# File 'lib/allocine/allocine_base.rb', line 82 def release_date document["release"]["releaseDate"] rescue nil end |
#trailer ⇒ Object
Returns a string containing the URL to the movie trailer.
52 53 54 |
# File 'lib/allocine/allocine_base.rb', line 52 def trailer document["trailer"]["href"] rescue nil end |
#trailer_id ⇒ Object
Returns a string containing trailer code.
47 48 49 |
# File 'lib/allocine/allocine_base.rb', line 47 def trailer_id document["trailer"]["code"] rescue nil end |
#user_rating ⇒ Object
Returns an int containing the number of user ratings
62 63 64 |
# File 'lib/allocine/allocine_base.rb', line 62 def document["statistics"]["userRating"] rescue nil end |