Class: KpApi::Film
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #budget ⇒ Object
-
#initialize(id) ⇒ Film
constructor
A new instance of Film.
- #peoples ⇒ Object
- #peoples_full ⇒ Object
- #rating ⇒ Object
- #rent ⇒ Object
- #view ⇒ Object
Methods inherited from Agent
#arr_data, #bool_data, #current_page, #data, #data2, #dn, #film_hash, #int_data, #json, #json2, #min_data, #next_page, #page_count, #people_hash, #s2a, #status, #status2, #str_data, #time_data, #url_data, #year_data
Constructor Details
#initialize(id) ⇒ Film
Returns a new instance of Film.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/kp_api/film.rb', line 5 def initialize(id) @id = id.to_i @url = "#{DOMAINS[:api]}#{METHODS[:get_film][:method]}?#{METHODS[:get_film][:id]}=#{id}" @url2 = "#{DOMAINS[:api]}#{METHODS[:get_staff][:method]}?#{METHODS[:get_staff][:id]}=#{id}" @json = json unless status raise ApiError.new(@json[:message], @json[:data]) end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/kp_api/film.rb', line 3 def id @id end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/kp_api/film.rb', line 3 def url @url end |
Instance Method Details
#budget ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/kp_api/film.rb', line 50 def budget { :gross_ru => int_data('budgetData', 'grossRU', nil), :gross_usa => int_data('budgetData', 'grossUSA', nil), :gross_world => int_data('budgetData', 'grossWorld', nil), :budget => int_data('budgetData', 'budget', nil) } end |
#peoples ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/kp_api/film.rb', line 59 def peoples unless @json['creators'].nil? @json['creators'].map { |items| items.map do |item| people_hash_old(item) end }.flatten end end |
#peoples_full ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/kp_api/film.rb', line 69 def peoples_full json2 unless @json2['creators'].nil? @json2['creators'].map { |items| items.map do |item| people_hash_old(item) end }.flatten end end |
#rating ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kp_api/film.rb', line 21 def { :rating_good_review => int_data('ratingData', 'ratingGoodReview', nil), :rating_good_review_vote_count => int_data('ratingData', 'ratingGoodReviewVoteCount'), :rating => int_data('ratingData', 'rating', nil, Float), :rating_vote_count => int_data('ratingData', 'ratingVoteCount'), :rating_await => int_data('ratingData', 'ratingAwait', nil), :rating_await_count => int_data('ratingData', 'ratingAwaitCount'), :rating_imdb => int_data('ratingData', 'ratingIMDb', nil, Float), :rating_imdb_vote_count => int_data('ratingData', 'ratingIMDbVoteCount'), :rating_film_critics => int_data('ratingData', 'ratingFilmCritics', nil), :rating_film_critics_vote_count => int_data('ratingData', 'ratingFilmCriticsVoteCount'), :rating_rf_critics => int_data('ratingData', 'ratingRFCritics', nil), :rating_fr_critics_vote_count => int_data('ratingData', 'ratingRFCriticsVoteCount') } end |
#rent ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kp_api/film.rb', line 38 def rent { :distributors => str_data('rentData', 'Distributors'), :premiere_world_country => str_data('rentData', 'premiereWorldCountry'), :distributor_release => str_data('rentData', 'distributorRelease'), :premiere_ru => time_data('rentData', 'premiereRU'), :premiere_world => time_data('rentData', 'premiereWorld'), :premiere_dvd => time_data('rentData', 'premiereDVD'), :premiere_blu_ray => time_data('rentData', 'premiereBluRay') } end |
#view ⇒ Object
17 18 19 |
# File 'lib/kp_api/film.rb', line 17 def view film_hash(@json).merge().merge(rent).merge(budget) end |