class KpApi::GlobalSearch
Attributes
keyword[RW]
url[RW]
Public Class Methods
new(keyword)
click to toggle source
# File lib/kp_api/global_search.rb, line 5 def initialize(keyword) @keyword = URI.encode(keyword) @url = "#{DOMAINS[:api]}#{METHODS[:search_global][:method]}?#{METHODS[:search_global][:keyword]}=#{@keyword}" @json = json unless status raise ApiError.new(@json[:message], @json[:data]) end end
Public Instance Methods
films()
click to toggle source
# File lib/kp_api/global_search.rb, line 39 def films unless @json['searchFilms'].nil? @json['searchFilms'].map do |film| film_hash(film, 'id') end end end
films_count()
click to toggle source
# File lib/kp_api/global_search.rb, line 19 def films_count if @json['searchFilmsCountResult'].nil? 0 else @json['searchFilmsCountResult'] end end
found?()
click to toggle source
# File lib/kp_api/global_search.rb, line 15 def found? films_count != 0 || peoples_count != 0 end
peoples()
click to toggle source
# File lib/kp_api/global_search.rb, line 47 def peoples unless @json['searchPeople'].nil? @json['searchPeople'].map do |name| people_hash(name) end end end
peoples_count()
click to toggle source
# File lib/kp_api/global_search.rb, line 27 def peoples_count if @json['searchPeoplesCountResult'].nil? 0 else @json['searchPeoplesCountResult'] end end
youmean()
click to toggle source
# File lib/kp_api/global_search.rb, line 35 def youmean film_hash(@json['youmean'], 'id') end