Class: TvMaze::Api
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
-
#initialize ⇒ Api
constructor
A new instance of Api.
- #url_for(action, params = {}) ⇒ Object
Constructor Details
#initialize ⇒ Api
Returns a new instance of Api.
9 10 11 |
# File 'lib/tv_maze/api.rb', line 9 def initialize self.base_url = "http://api.tvmaze.com/".freeze end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
7 8 9 |
# File 'lib/tv_maze/api.rb', line 7 def base_url @base_url end |
Instance Method Details
#url_for(action, params = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tv_maze/api.rb', line 13 def url_for(action, params={}) url = URI.join(base_url, action) if params[:embed] params['embed[]'] = params.delete(:embed) end url.query = URI.encode_www_form(params) if params url.to_s end |