Class: KpApi::Today
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #film_ids ⇒ Object
-
#initialize(city_id = 1, country_id = 2) ⇒ Today
constructor
A new instance of Today.
- #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(city_id = 1, country_id = 2) ⇒ Today
Returns a new instance of Today.
5 6 7 8 9 10 11 12 |
# File 'lib/kp_api/today.rb', line 5 def initialize(city_id=1, country_id=2) @url = "#{DOMAINS[:api]}#{METHODS[:get_today_films][:method]}?cityID=#{city_id}&countryID=#{country_id}" @json = json unless status raise ApiError.new(@json[:message], @json[:data]) end end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/kp_api/today.rb', line 3 def url @url end |
Instance Method Details
#film_ids ⇒ Object
41 42 43 |
# File 'lib/kp_api/today.rb', line 41 def film_ids films.map{|film| int_data(String, film['id'], nil) }.compact end |
#view ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kp_api/today.rb', line 14 def view films.map do |film| { id: int_data(String, film['id' ]), kp_type: str_data(String, film['type' ]), name_ru: str_data(String, film['nameRU' ]), name_en: str_data(String, film['nameEN' ]), slogan: str_data(String, film['slogan' ]), description: str_data(String, film['description' ]), poster_url: url_data(String, film['posterURL' ], film["id"], :film), year: int_data(String, film['year' ]), reviews_count: int_data(String, film['reviewsCount']), duration: min_data(String, film['filmLength' ]), countries: arr_data(String, film['country' ]), genres: arr_data(String, film['genre' ]), video: film['videoURL'], is_sequel_or_prequel: bool_data(String, film['hasSequelsAndPrequelsFilms']), is_similar_films: bool_data(String, film['hasRelatedFilms' ]), is_imax: bool_data(String, film['isIMAX' ]), is_3d: bool_data(String, film['is3D' ]), rating_mpaa: str_data(String, film['ratingMPAA' ]), minimal_age: int_data(String, film['ratingAgeLimits' ]) } end end |