Class: KpApi::LiveSearch
Instance Attribute Summary collapse
-
#keyword ⇒ Object
Returns the value of attribute keyword.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #found? ⇒ Boolean
-
#initialize(keyword) ⇒ LiveSearch
constructor
A new instance of LiveSearch.
- #items ⇒ 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(keyword) ⇒ LiveSearch
Returns a new instance of LiveSearch.
5 6 7 8 9 10 11 12 13 |
# File 'lib/kp_api/live_search.rb', line 5 def initialize(keyword) @keyword = URI.encode(keyword) @url = "#{DOMAINS[:api]}#{METHODS[:search_live][:method]}?#{METHODS[:search_live][:keyword]}=#{@keyword}" @json = json unless status raise ApiError.new(@json[:message], @json[:data]) end end |
Instance Attribute Details
#keyword ⇒ Object
Returns the value of attribute keyword.
3 4 5 |
# File 'lib/kp_api/live_search.rb', line 3 def keyword @keyword end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/kp_api/live_search.rb', line 3 def url @url end |
Instance Method Details
#found? ⇒ Boolean
15 16 17 |
# File 'lib/kp_api/live_search.rb', line 15 def found? !@json['items'].nil? end |
#items ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/kp_api/live_search.rb', line 19 def items if found? @json['items'].map{|item| if item['type'] == "KPFilmObject" film_hash(item, 'id') elsif item['type'] == "KPPeopleObject" people_hash(item) end }.compact end end |