Class: Firmapi::Companies
- Inherits:
-
Object
- Object
- Firmapi::Companies
- Defined in:
- lib/firmapi/companies.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#number_of_pages ⇒ Object
readonly
Returns the value of attribute number_of_pages.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
- #add_company(company) ⇒ Object
-
#initialize(options, params) ⇒ Companies
constructor
A new instance of Companies.
- #next_page ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(options, params) ⇒ Companies
Returns a new instance of Companies.
6 7 8 9 10 11 12 13 |
# File 'lib/firmapi/companies.rb', line 6 def initialize(, params) @results = ["results"] @size = ["size"] @page = ["page"] @number_of_pages = ["number_of_pages"] @list = [] @params = params end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
4 5 6 |
# File 'lib/firmapi/companies.rb', line 4 def list @list end |
#number_of_pages ⇒ Object (readonly)
Returns the value of attribute number_of_pages.
4 5 6 |
# File 'lib/firmapi/companies.rb', line 4 def number_of_pages @number_of_pages end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
4 5 6 |
# File 'lib/firmapi/companies.rb', line 4 def page @page end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/firmapi/companies.rb', line 4 def params @params end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
4 5 6 |
# File 'lib/firmapi/companies.rb', line 4 def results @results end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/firmapi/companies.rb', line 4 def size @size end |
Class Method Details
.where(params) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/firmapi/companies.rb', line 29 def self.where(params) @params = params response = API.new.get '/companies', params if response.status == 200 json = response.body companies = self.new(json["result"]["search"], params) json["result"]["list"].each do |company_info| companies.add_company Firmapi::Company.new company_info end companies end end |
Instance Method Details
#add_company(company) ⇒ Object
15 16 17 |
# File 'lib/firmapi/companies.rb', line 15 def add_company(company) @list << company end |
#next_page ⇒ Object
23 24 25 26 27 |
# File 'lib/firmapi/companies.rb', line 23 def next_page params[:page] = page + 1 Companies.where(params) end |
#to_a ⇒ Object
19 20 21 |
# File 'lib/firmapi/companies.rb', line 19 def to_a @list end |