Class: Tvdbjson::Series
- Inherits:
-
Object
- Object
- Tvdbjson::Series
- Extended by:
- Requestable
- Includes:
- Hashable
- Defined in:
- lib/tvdbjson/series.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#banner_url ⇒ Object
Returns the value of attribute banner_url.
-
#first_aired ⇒ Object
Returns the value of attribute first_aired.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#network ⇒ Object
Returns the value of attribute network.
-
#overview ⇒ Object
Returns the value of attribute overview.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
- .from_response(response) ⇒ Object
- .search_by_imdb(str, authentication) ⇒ Object
- .search_by_name(str, authentication) ⇒ Object
- .search_by_zap2it_id(str, authentication) ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Series
constructor
A new instance of Series.
Methods included from Requestable
build_uri, send_authenticated_request
Methods included from Hashable
Constructor Details
#initialize(options = {}) ⇒ Series
Returns a new instance of Series.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/tvdbjson/series.rb', line 7 def initialize( = {}) @id = [:id] @name = [:name] @overview = [:overview] @network = [:network] @banner_url = [:banner_url] @first_aired = [:first_aired] @status = [:status] @aliases = [:aliases] end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
5 6 7 |
# File 'lib/tvdbjson/series.rb', line 5 def aliases @aliases end |
#banner_url ⇒ Object
Returns the value of attribute banner_url.
5 6 7 |
# File 'lib/tvdbjson/series.rb', line 5 def @banner_url end |
#first_aired ⇒ Object
Returns the value of attribute first_aired.
5 6 7 |
# File 'lib/tvdbjson/series.rb', line 5 def first_aired @first_aired end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/tvdbjson/series.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/tvdbjson/series.rb', line 5 def name @name end |
#network ⇒ Object
Returns the value of attribute network.
5 6 7 |
# File 'lib/tvdbjson/series.rb', line 5 def network @network end |
#overview ⇒ Object
Returns the value of attribute overview.
5 6 7 |
# File 'lib/tvdbjson/series.rb', line 5 def overview @overview end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/tvdbjson/series.rb', line 5 def status @status end |
Class Method Details
.from_response(response) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/tvdbjson/series.rb', line 57 def self.from_response(response) results_array = [] begin response.parsed_response["data"].each do |record| hash = {} hash[:id] = record["id"] hash[:name] = record["seriesName"] hash[:overview] = record["overview"] hash[:network] = record["network"] hash[:banner_url] = "https://thetvdb.com/banners/" + record["banner"] hash[:first_aired] = record["firstAired"] hash[:status] = record["status"] hash[:aliases] = record["aliases"] result = Series.new(hash) results_array << result end rescue NoMethodError # Means an empty result set was found, don't do anything special # here as this method will return an empty array. end results_array end |
.search_by_imdb(str, authentication) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tvdbjson/series.rb', line 31 def self.search_by_imdb(str, authentication) raise Tvdbjson::RequiredSearchParamMissingError if !str raise Tvdbjson::AuthenticationObjectMissingError unless authentication.kind_of?(Tvdbjson::Authentication) hash = { :method => "GET", :uri => "/search/series", :after_action => "Tvdbjson::Series.from_response(response)", :params => { "imdbId" => str } } send_authenticated_request(hash, authentication) end |
.search_by_name(str, authentication) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tvdbjson/series.rb', line 18 def self.search_by_name(str, authentication) raise Tvdbjson::RequiredSearchParamMissingError if !str raise Tvdbjson::AuthenticationObjectMissingError unless authentication.kind_of?(Tvdbjson::Authentication) hash = { :method => "GET", :uri => "/search/series", :after_action => "Tvdbjson::Series.from_response(response)", :params => { "name" => str } } send_authenticated_request(hash, authentication) end |
.search_by_zap2it_id(str, authentication) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/tvdbjson/series.rb', line 44 def self.search_by_zap2it_id(str, authentication) raise Tvdbjson::RequiredSearchParamMissingError if !str raise Tvdbjson::AuthenticationObjectMissingError unless authentication.kind_of?(Tvdbjson::Authentication) hash = { :method => "GET", :uri => "/search/series", :after_action => "Tvdbjson::Series.from_response(response)", :params => { "zap2itId" => str } } send_authenticated_request(hash, authentication) end |