Class: Tmdb::Connection
- Inherits:
-
Object
- Object
- Tmdb::Connection
- Includes:
- HTTParty, GenreMethods, MovieMethods, PeopleMethods, SearchMethods
- Defined in:
- lib/tmdb/connection.rb
Constant Summary collapse
- CONNECTIONS_PER_MINUTE =
150.0
- CONNECTION_SPACING =
60.0/CONNECTIONS_PER_MINUTE
- TMDB_URL =
"http://api.themoviedb.org/3"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
debug_output $stdout.
-
#rate_limit_time ⇒ Object
debug_output $stdout.
-
#request ⇒ Object
debug_output $stdout.
-
#response ⇒ Object
debug_output $stdout.
Instance Method Summary collapse
-
#initialize(api_key = ENV["TMDB_API_KEY"]) ⇒ Connection
constructor
A new instance of Connection.
- #rate_limit ⇒ Object
Methods included from GenreMethods
#genre_movie_list, #genre_movies, #genre_tv_list
Methods included from PeopleMethods
Methods included from MovieMethods
Constructor Details
#initialize(api_key = ENV["TMDB_API_KEY"]) ⇒ Connection
Returns a new instance of Connection.
37 38 39 40 |
# File 'lib/tmdb/connection.rb', line 37 def initialize(api_key = ENV["TMDB_API_KEY"]) @api_key = api_key Tmdb.connection = self end |
Instance Attribute Details
#api_key ⇒ Object
debug_output $stdout
31 32 33 |
# File 'lib/tmdb/connection.rb', line 31 def api_key @api_key end |
#rate_limit_time ⇒ Object
debug_output $stdout
31 32 33 |
# File 'lib/tmdb/connection.rb', line 31 def rate_limit_time @rate_limit_time end |
#request ⇒ Object
debug_output $stdout
31 32 33 |
# File 'lib/tmdb/connection.rb', line 31 def request @request end |
#response ⇒ Object
debug_output $stdout
31 32 33 |
# File 'lib/tmdb/connection.rb', line 31 def response @response end |
Instance Method Details
#rate_limit ⇒ Object
43 44 45 46 47 48 |
# File 'lib/tmdb/connection.rb', line 43 def rate_limit while(Time.now.to_f<@rate_limit_time.to_f+CONNECTION_SPACING) sleep 0.1 end @rate_limit_time = Time.now end |