class KpApi::FilmSearch
Attributes
keyword[RW]
url[RW]
Public Class Methods
new(keyword)
click to toggle source
# File lib/kp_api/film_search.rb, line 5 def initialize(keyword) @keyword = URI.encode(keyword) @page = 1 gen_url @json = json @page_count = @json['pagesCount'] end
Public Instance Methods
films_count()
click to toggle source
# File lib/kp_api/film_search.rb, line 17 def films_count @json['searchFilmsCountResult'] end
found?()
click to toggle source
# File lib/kp_api/film_search.rb, line 13 def found? @page_count != 0 end
view()
click to toggle source
# File lib/kp_api/film_search.rb, line 21 def view @json['searchFilms'].map do |film| film_hash(film, 'id') end end
Private Instance Methods
gen_url()
click to toggle source
# File lib/kp_api/film_search.rb, line 29 def gen_url @url = [ "#{DOMAINS[:api]}#{METHODS[:search_film][:method]}", "?#{METHODS[:search_film][:keyword]}=#{@keyword}", "&#{METHODS[:search_film][:page]}=#{@page}" ].join('') end