Class: KpApi::PeopleSearch

Inherits:
Agent
  • Object
show all
Defined in:
lib/kp_api/people_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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) ⇒ PeopleSearch

Returns a new instance of PeopleSearch.



5
6
7
8
9
10
11
# File 'lib/kp_api/people_search.rb', line 5

def initialize(keyword)
  @keyword    = URI.encode(keyword)
  @page       = 1
  gen_url
  @json       = json
  @page_count = @json['pagesCount']
end

Instance Attribute Details

#keywordObject

Returns the value of attribute keyword.



3
4
5
# File 'lib/kp_api/people_search.rb', line 3

def keyword
  @keyword
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/kp_api/people_search.rb', line 3

def url
  @url
end

Instance Method Details

#found?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/kp_api/people_search.rb', line 13

def found?
  @page_count != 0
end

#peoples_countObject



17
18
19
# File 'lib/kp_api/people_search.rb', line 17

def peoples_count
  @json['searchPeoplesCountResult']
end

#viewObject



21
22
23
24
25
# File 'lib/kp_api/people_search.rb', line 21

def view
  @json['searchPeople'].map do |film|
    people_hash(film)
  end
end