crunchbase-ruby-library 0.1.7 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +66 -0
  3. data/.rubocop_todo.yml +47 -0
  4. data/.travis.yml +12 -0
  5. data/Gemfile +4 -0
  6. data/README.md +44 -54
  7. data/Rakefile +4 -1
  8. data/bin/console +15 -0
  9. data/bin/setup +8 -0
  10. data/crunchbase-ruby-library.gemspec +15 -12
  11. data/lib/crunchbase.rb +12 -3
  12. data/lib/crunchbase/api.rb +110 -102
  13. data/lib/crunchbase/client.rb +50 -0
  14. data/lib/crunchbase/exception.rb +13 -11
  15. data/lib/crunchbase/model.rb +50 -48
  16. data/lib/crunchbase/model/acquired_by.rb +23 -20
  17. data/lib/crunchbase/model/acquiree.rb +2 -1
  18. data/lib/crunchbase/model/acquirer.rb +2 -1
  19. data/lib/crunchbase/model/acquisition.rb +16 -19
  20. data/lib/crunchbase/model/address.rb +4 -6
  21. data/lib/crunchbase/model/advisory_role.rb +2 -2
  22. data/lib/crunchbase/model/board_members_and_advisor.rb +10 -9
  23. data/lib/crunchbase/model/category.rb +6 -7
  24. data/lib/crunchbase/model/competitor.rb +3 -2
  25. data/lib/crunchbase/model/current_team.rb +7 -11
  26. data/lib/crunchbase/model/customer.rb +3 -2
  27. data/lib/crunchbase/model/degree.rb +4 -5
  28. data/lib/crunchbase/model/entity.rb +98 -108
  29. data/lib/crunchbase/model/error.rb +3 -4
  30. data/lib/crunchbase/model/featured_team.rb +19 -0
  31. data/lib/crunchbase/model/founded_company.rb +2 -3
  32. data/lib/crunchbase/model/founder.rb +3 -4
  33. data/lib/crunchbase/model/fund.rb +8 -11
  34. data/lib/crunchbase/model/fund_raise.rb +7 -8
  35. data/lib/crunchbase/model/funding_round.rb +29 -24
  36. data/lib/crunchbase/model/headquarter.rb +2 -1
  37. data/lib/crunchbase/model/image.rb +6 -7
  38. data/lib/crunchbase/model/investment.rb +20 -27
  39. data/lib/crunchbase/model/investor.rb +6 -7
  40. data/lib/crunchbase/model/ipo.rb +12 -12
  41. data/lib/crunchbase/model/job.rb +11 -10
  42. data/lib/crunchbase/model/location.rb +20 -11
  43. data/lib/crunchbase/model/member.rb +3 -4
  44. data/lib/crunchbase/model/membership.rb +7 -8
  45. data/lib/crunchbase/model/new.rb +5 -6
  46. data/lib/crunchbase/model/office.rb +3 -4
  47. data/lib/crunchbase/model/organization.rb +39 -38
  48. data/lib/crunchbase/model/organization_summary.rb +7 -8
  49. data/lib/crunchbase/model/owned_by.rb +4 -5
  50. data/lib/crunchbase/model/parent_location.rb +3 -3
  51. data/lib/crunchbase/model/past_team.rb +7 -11
  52. data/lib/crunchbase/model/person.rb +53 -46
  53. data/lib/crunchbase/model/person_summary.rb +13 -14
  54. data/lib/crunchbase/model/primary_affiliation.rb +6 -6
  55. data/lib/crunchbase/model/primary_image.rb +3 -3
  56. data/lib/crunchbase/model/primary_location.rb +8 -7
  57. data/lib/crunchbase/model/product.rb +14 -13
  58. data/lib/crunchbase/model/product_summary.rb +4 -5
  59. data/lib/crunchbase/model/school.rb +3 -2
  60. data/lib/crunchbase/model/search.rb +39 -40
  61. data/lib/crunchbase/model/search_result.rb +7 -6
  62. data/lib/crunchbase/model/simple_organization.rb +9 -10
  63. data/lib/crunchbase/model/sub_organization.rb +3 -4
  64. data/lib/crunchbase/model/video.rb +4 -5
  65. data/lib/crunchbase/model/website.rb +7 -11
  66. data/lib/crunchbase/request.rb +8 -0
  67. data/lib/crunchbase/request/client.rb +69 -0
  68. data/lib/crunchbase/version.rb +2 -1
  69. data/spec/crunchbase.yml.example +2 -2
  70. data/spec/crunchbase/client_spec.rb +25 -0
  71. data/spec/crunchbase/data/board_members_and_advisors/facebook.json +462 -0
  72. data/spec/crunchbase/data/categories/facebook.json +67 -0
  73. data/spec/crunchbase/data/current_team/facebook.json +4335 -0
  74. data/spec/crunchbase/data/featured_team/facebook.json +286 -0
  75. data/spec/crunchbase/data/funding_rounds/37bd05f961af726ba3c1b279da842805.json +484 -0
  76. data/spec/crunchbase/data/funding_rounds/facebook.json +2049 -0
  77. data/spec/crunchbase/data/headquarters/facebook.json +50 -0
  78. data/spec/crunchbase/data/investors/facebook.json +776 -0
  79. data/spec/crunchbase/data/news/facebook.json +1426 -0
  80. data/spec/crunchbase/data/news/facebook_2.json +1426 -0
  81. data/spec/crunchbase/data/offices/facebook.json +50 -0
  82. data/spec/crunchbase/data/organizations/crunchbase.json +2845 -0
  83. data/spec/crunchbase/data/organizations/ekohe.json +654 -0
  84. data/spec/crunchbase/data/organizations/facebook-without-relationships.json +45 -0
  85. data/spec/crunchbase/data/organizations/facebook.json +6723 -0
  86. data/spec/crunchbase/data/organizations/mx-media-llc.json +7 -0
  87. data/spec/crunchbase/data/past_team/facebook.json +4336 -0
  88. data/spec/crunchbase/data/people/facebook_founders.json +148 -0
  89. data/spec/crunchbase/data/people/mark-zuckerberg.json +2602 -0
  90. data/spec/crunchbase/data/websites/facebook.json +74 -0
  91. data/spec/crunchbase/model/board_members_and_advisor_spec.rb +39 -11
  92. data/spec/crunchbase/model/category_spec.rb +47 -0
  93. data/spec/crunchbase/model/current_team_spec.rb +50 -0
  94. data/spec/crunchbase/model/featured_team_spec.rb +40 -0
  95. data/spec/crunchbase/model/founders_spec.rb +49 -0
  96. data/spec/crunchbase/model/fund_raise_spec.rb +4 -24
  97. data/spec/crunchbase/model/funding_round_spec.rb +75 -32
  98. data/spec/crunchbase/model/headquarter_spec.rb +37 -0
  99. data/spec/crunchbase/model/investment_spec.rb +4 -15
  100. data/spec/crunchbase/model/investor_spec.rb +37 -0
  101. data/spec/crunchbase/model/new_spec.rb +86 -0
  102. data/spec/crunchbase/model/office_spec.rb +29 -9
  103. data/spec/crunchbase/model/organization_spec.rb +160 -34
  104. data/spec/crunchbase/model/past_team_spec.rb +36 -14
  105. data/spec/crunchbase/model/person_spec.rb +21 -19
  106. data/spec/crunchbase/model/product_spec.rb +4 -31
  107. data/spec/crunchbase/model/search_spec.rb +25 -49
  108. data/spec/crunchbase/model/website_spec.rb +36 -9
  109. data/spec/crunchbase/support/api_helper.rb +19 -0
  110. data/spec/spec_helper.rb +14 -4
  111. metadata +103 -6
@@ -1,19 +1,18 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class OrganizationSummary < Crunchbase::Model::Entity
5
-
5
+ class OrganizationSummary < Entity
6
6
  attr_reader :permalink, :api_path, :web_path, :name, :primary_role, :short_description, :profile_image_url,
7
- :domain, :homepage_url, :facebook_url, :twitter_url, :linkedin_url, :city_name, :region_name, :country_code,
7
+ :domain, :homepage_url, :facebook_url, :twitter_url, :linkedin_url, :city_name, :region_name, :country_code,
8
8
  :created_at, :updated_at
9
9
 
10
10
  def property_keys
11
- %w[
11
+ %w(
12
12
  permalink api_path web_path name primary_role short_description profile_image_url
13
- domain homepage_url facebook_url twitter_url linkedin_url city_name region_name country_code
13
+ domain homepage_url facebook_url twitter_url linkedin_url city_name region_name country_code
14
14
  created_at updated_at
15
- ]
15
+ )
16
16
  end
17
-
18
17
  end
19
- end
18
+ end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class OwnedBy < Crunchbase::Model::Entity
5
-
5
+ class OwnedBy < Entity
6
6
  attr_reader :name, :api_path, :web_path, :created_at, :updated_at
7
7
 
8
8
  def initialize(json)
@@ -10,10 +10,9 @@ module Crunchbase::Model
10
10
  end
11
11
 
12
12
  def property_keys
13
- %w[
13
+ %w(
14
14
  name api_path web_path created_at updated_at
15
- ]
15
+ )
16
16
  end
17
-
18
17
  end
19
18
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class ParentLocation < Crunchbase::Model::Location
5
-
5
+ class ParentLocation < Location
6
6
  end
7
- end
7
+ end
@@ -1,24 +1,20 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class PastTeam < Crunchbase::Model::Job
5
-
5
+ class PastTeam < Job
6
6
  RESOURCE_LIST = 'past_team'
7
7
 
8
8
  attr_reader :person
9
9
 
10
10
  def initialize(json)
11
11
  super
12
-
13
- unless (relationships = json['relationships']).nil?
14
- instance_relationships_object(Crunchbase::Model::Person, 'person', relationships['person'])
15
- end
16
12
  end
17
13
 
18
- # Factory method to return an instance from a permalink
19
- def self.get(permalink)
20
- nil
14
+ def relationship_lists
15
+ {
16
+ 'person' => Person
17
+ }
21
18
  end
22
-
23
19
  end
24
- end
20
+ end
@@ -1,55 +1,62 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- module Crunchbase::Model
4
- class Person < Crunchbase::Model::Entity
5
-
6
- RESOURCE_LIST = RESOURCE_NAME = 'people'
7
-
8
- attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :gender, :also_known_as, :bio, :profile_image_url,
9
- :role_investor, :born_on, :born_on_trust_code, :is_deceased, :died_on, :died_on_trust_code,
10
- :created_at, :updated_at
11
-
12
- attr_reader :primary_affiliation, :primary_location, :primary_image, :websites, :degrees, :jobs,
13
- :advisory_roles, :founded_companies, :investments, :memberships, :images, :videos, :news
14
-
15
- attr_reader :primary_affiliation_total_items, :primary_location_total_items,
16
- :primary_image_total_items, :websites_total_items, :degrees_total_items, :jobs_total_items,
17
- :advisory_roles_total_items, :founded_companies_total_items,
18
- :investments_total_items, :memberships_total_items, :images_total_items, :videos_total_items,
19
- :news_total_items
20
-
21
- def initialize(json)
22
- super
23
-
24
- unless (relationships = json['relationships']).nil?
25
- set_relationships_object(Crunchbase::Model::PrimaryAffiliation, 'primary_affiliation', relationships['primary_affiliation'])
26
- set_relationships_object(Crunchbase::Model::PrimaryAffiliation, 'primary_location', relationships['primary_location'])
27
- set_relationships_object(Crunchbase::Model::PrimaryImage, 'primary_image', relationships['primary_image'])
28
- set_relationships_object(Crunchbase::Model::Website, 'websites', relationships['websites'])
29
- set_relationships_object(Crunchbase::Model::Degree, 'degrees', relationships['degrees'])
30
- set_relationships_object(Crunchbase::Model::Job, 'jobs', relationships['jobs'])
31
- set_relationships_object(Crunchbase::Model::AdvisoryRole, 'advisory_roles', relationships['advisor_at'])
32
- set_relationships_object(Crunchbase::Model::FoundedCompany, 'founded_companies', relationships['founded_companies'])
33
- set_relationships_object(Crunchbase::Model::Investment, 'investments', relationships['investments'])
34
- set_relationships_object(Crunchbase::Model::Membership, 'memberships', relationships['memberships'])
35
- set_relationships_object(Crunchbase::Model::Image, 'images', relationships['images'])
36
- set_relationships_object(Crunchbase::Model::Video, 'videos', relationships['videos'])
37
- set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
4
+ module Crunchbase
5
+ module Model
6
+ class Person < Entity
7
+ RESOURCE_LIST = RESOURCE_NAME = 'people'
8
+
9
+ attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :gender, :also_known_as, :bio, :profile_image_url,
10
+ :role_investor, :born_on, :born_on_trust_code, :is_deceased, :died_on, :died_on_trust_code, :name,
11
+ :created_at, :updated_at
12
+
13
+ attr_reader :primary_affiliation, :primary_location, :primary_image, :websites, :degrees, :jobs,
14
+ :advisory_roles, :founded_companies, :investments, :memberships, :images, :videos, :news
15
+
16
+ attr_reader :primary_affiliation_total_items, :primary_location_total_items,
17
+ :primary_image_total_items, :websites_total_items, :degrees_total_items, :jobs_total_items,
18
+ :advisory_roles_total_items, :founded_companies_total_items,
19
+ :investments_total_items, :memberships_total_items, :images_total_items, :videos_total_items,
20
+ :news_total_items
21
+
22
+ def initialize(json)
23
+ super(json)
38
24
  end
39
- end
40
25
 
41
- def property_keys
42
- %w[
43
- permalink api_path web_path first_name last_name gender also_known_as bio profile_image_url
44
- role_investor born_on born_on_trust_code is_deceased died_on died_on_trust_code
45
- created_at updated_at
46
- ]
47
- end
26
+ def relationship_lists
27
+ {
28
+ 'primary_affiliation' => PrimaryAffiliation,
29
+ 'primary_location' => PrimaryLocation,
30
+ 'primary_image' => PrimaryImage,
31
+ 'websites' => Website,
32
+ 'degrees' => Degree,
33
+ 'jobs' => Job,
34
+ 'advisory_roles' => AdvisoryRole,
35
+ 'founded_companies' => FoundedCompany,
36
+ 'investments' => Investment,
37
+ 'memberships' => Membership,
38
+ 'images' => Image,
39
+ 'videos' => Video,
40
+ 'news' => New
41
+ }
42
+ end
48
43
 
49
- def date_keys
50
- %w[ born_on died_on ]
51
- end
44
+ def property_keys
45
+ %w(
46
+ permalink api_path web_path first_name last_name gender also_known_as bio profile_image_url
47
+ role_investor born_on born_on_trust_code is_deceased died_on died_on_trust_code
48
+ created_at updated_at
49
+ )
50
+ end
52
51
 
52
+ def date_keys
53
+ %w(born_on died_on)
54
+ end
53
55
 
56
+ # custom name from first name and last name
57
+ def name
58
+ [first_name, last_name].compact.join(' ')
59
+ end
60
+ end
54
61
  end
55
62
  end
@@ -1,23 +1,22 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class PersonSummary < Crunchbase::Model::Entity
5
-
6
- attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :title,
7
- :organization_permalink, :organization_api_path, :organization_web_path, :organization_name,
8
- :profile_image_url, :homepage_url, :facebook_url, :twitter_url, :linkedin_url,
9
- :city_name, :region_name, :country_code,
5
+ class PersonSummary < Entity
6
+ attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :title,
7
+ :organization_permalink, :organization_api_path, :organization_web_path, :organization_name,
8
+ :profile_image_url, :homepage_url, :facebook_url, :twitter_url, :linkedin_url,
9
+ :city_name, :region_name, :country_code,
10
10
  :created_at, :updated_at
11
11
 
12
12
  def property_keys
13
- %w[
14
- permalink api_path web_path first_name last_name title
15
- organization_permalink organization_api_path organization_web_path organization_name
16
- profile_image_url homepage_url facebook_url twitter_url linkedin_url
17
- city_name region_name country_code
13
+ %w(
14
+ permalink api_path web_path first_name last_name title
15
+ organization_permalink organization_api_path organization_web_path organization_name
16
+ profile_image_url homepage_url facebook_url twitter_url linkedin_url
17
+ city_name region_name country_code
18
18
  created_at updated_at
19
- ]
19
+ )
20
20
  end
21
-
22
21
  end
23
- end
22
+ end
@@ -1,22 +1,22 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class PrimaryAffiliation < Crunchbase::Model::Job
5
-
5
+ class PrimaryAffiliation < Job
6
6
  attr_reader :organization
7
7
 
8
8
  def initialize(json)
9
9
  super
10
10
 
11
11
  unless (relationships = json['relationships']).nil?
12
- set_relationships_object(Crunchbase::Model::Organization, 'organization', relationships['organization'])
12
+ set_relationships_object(Organization, 'organization', relationships['organization'])
13
13
  end
14
14
  end
15
15
 
16
- def set_relationships_object(object_name, key, item)
16
+ def set_relationships_object(kclass_name, key, item)
17
17
  return unless item
18
18
 
19
- instance_variable_set "@#{key}", ( object_name.new(item) || nil )
19
+ instance_variable_set "@#{key}", (kclass_name.new(item) || nil)
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class PrimaryImage < Crunchbase::Model::Image
5
-
5
+ class PrimaryImage < Image
6
6
  end
7
- end
7
+ end
@@ -1,17 +1,18 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class PrimaryLocation < Crunchbase::Model::Location
5
-
5
+ class PrimaryLocation < Location
6
6
  attr_reader :parent_locations
7
7
 
8
8
  def initialize(json)
9
9
  super
10
-
11
- unless (relationships = json['relationships']).nil?
12
- set_relationships_object(Crunchbase::Model::ParentLocation, 'parent_locations', relationships['parent_locations'])
13
- end
14
10
  end
15
11
 
12
+ def relationship_lists
13
+ {
14
+ 'parent_locations' => ParentLocation
15
+ }
16
+ end
16
17
  end
17
- end
18
+ end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class Product < Crunchbase::Model::Entity
5
-
5
+ class Product < Entity
6
6
  RESOURCE_LIST = RESOURCE_NAME = 'products'
7
7
 
8
8
  attr_reader :permalink, :api_path, :web_path, :name, :also_known_as,
@@ -20,28 +20,29 @@ module Crunchbase::Model
20
20
 
21
21
  def initialize(json)
22
22
  super
23
+ end
23
24
 
24
- unless (relationships = json['relationships']).nil?
25
- set_relationships_object(Crunchbase::Model::Category, 'categories', relationships['categories'])
26
- set_relationships_object(Crunchbase::Model::PrimaryImage, 'primary_image', relationships['primary_image'])
27
- set_relationships_object(Crunchbase::Model::Image, 'images', relationships['images'])
28
- set_relationships_object(Crunchbase::Model::Video, 'video', relationships['video'])
29
- set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
30
- end
25
+ def relationship_lists
26
+ {
27
+ 'categories' => Category,
28
+ 'primary_image' => PrimaryImage,
29
+ 'images' => Image,
30
+ 'video' => Video,
31
+ 'news' => New
32
+ }
31
33
  end
32
34
 
33
35
  def property_keys
34
- %w[
36
+ %w(
35
37
  permalink api_path web_path name also_known_as
36
38
  lifecycle_stage short_description description profile_image_url
37
39
  launched_on launched_on_trust_code closed_on closed_on_trust_code
38
40
  homepage_url created_at updated_at
39
- ]
41
+ )
40
42
  end
41
43
 
42
44
  def date_keys
43
- %w[launched_on closed_on]
45
+ %w(launched_on closed_on)
44
46
  end
45
-
46
47
  end
47
48
  end
@@ -1,19 +1,18 @@
1
+ # frozen_string_literal: true
1
2
  module Crunchbase::Model
2
- class ProductSummary < Crunchbase::Model::Entity
3
-
3
+ class ProductSummary < Entity
4
4
  attr_reader :permalink, :api_path, :web_path, :name, :short_description,
5
5
  :owner_permalink, :owner_api_path, :owner_web_path, :owner_name,
6
6
  :profile_image_url, :homepage_url, :facebook_url, :twitter_url, :linkedin_url,
7
7
  :created_at, :updated_at
8
8
 
9
-
10
9
  def property_keys
11
- %w[
10
+ %w(
12
11
  permalink api_path web_path name short_description
13
12
  owner_permalink owner_api_path owner_web_path owner_name
14
13
  profile_image_url homepage_url facebook_url twitter_url linkedin_url
15
14
  created_at updated_at
16
- ]
15
+ )
17
16
  end
18
17
  end
19
18
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Crunchbase::Model
4
- class School < Crunchbase::Model::Organization
5
+ class School < Organization
5
6
  end
6
- end
7
+ end
@@ -1,55 +1,54 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- module Crunchbase::Model
4
- class Search < Crunchbase::Model::Entity
5
- include Enumerable
4
+ module Crunchbase
5
+ module Model
6
+ class Search < Entity
7
+ include Enumerable
6
8
 
7
- attr_reader :total_items, :per_page, :pages, :current_page, :prev_page_url, :next_page_url, :sort_order, :results
9
+ attr_reader :total_items, :per_page, :pages, :current_page, :prev_page_url, :next_page_url
10
+ attr_reader :sort_order, :results
8
11
 
9
- alias :length :total_items
10
- alias :size :total_items
11
- alias :items :results
12
+ alias length total_items
13
+ alias size total_items
14
+ alias items results
12
15
 
13
- def initialize(query, json, _model)
14
- @query = query
15
- @results = []
16
- @total_items = 0
17
- @pages = 0
16
+ def initialize(query, json, kclass)
17
+ @query = query
18
+ @results = []
19
+ @total_items = 0
20
+ @pages = 0
18
21
 
19
- populate_results(json, _model) if json['error'].nil?
20
- end
21
-
22
-
23
- def populate_results(json, _model)
24
- @results = if json["items"].nil?
25
- []
26
- else
27
- json["items"].map{|r| _model.new(r)}
22
+ populate_results(json, kclass) if json['error'].nil?
28
23
  end
29
24
 
30
- @total_items = json['paging']['total_items']
31
- @per_page = json['paging']['items_per_page']
32
- @pages = json['paging']['number_of_pages']
33
- @current_page = json['paging']['current_page']
34
- @prev_page_url = json['paging']['prev_page_url']
35
- @next_page_url = json['paging']['next_page_url']
36
- @sort_order = json['paging']['sort_order']
37
- end
25
+ def populate_results(json, kclass)
26
+ @results = []
27
+ @results = json['items'].map { |r| kclass.new(r) } unless json['items'].nil?
28
+
29
+ @total_items = json['paging']['total_items']
30
+ @per_page = json['paging']['items_per_page']
31
+ @pages = json['paging']['number_of_pages']
32
+ @current_page = json['paging']['current_page']
33
+ @prev_page_url = json['paging']['prev_page_url']
34
+ @next_page_url = json['paging']['next_page_url']
35
+ @sort_order = json['paging']['sort_order']
36
+ end
38
37
 
39
- # Finds an entity by its name. Uses two HTTP requests; one to find the
40
- # permalink, and another to request the actual entity.
41
- def self.search(options, resource_list)
42
- model_name = get_model_name(resource_list)
38
+ # Finds an entity by its name. Uses two HTTP requests; one to find the
39
+ # permalink, and another to request the actual entity.
40
+ def self.search(options, resource_list)
41
+ model_name = kclass_name(resource_list)
43
42
 
44
- raise 'Unknown type error!' if model_name.nil?
43
+ raise 'Unknown type error!' if model_name.nil?
45
44
 
46
- return Search.new options, Crunchbase::API.search( options, resource_list ), model_name
47
- end
45
+ Search.new options, API.search(options, resource_list), model_name
46
+ end
48
47
 
49
- # Factory method to return an instance from a permalink
50
- def self.get(permalink)
51
- nil
48
+ # Factory method to return an instance from a permalink
49
+ def self.get(_permalink)
50
+ nil
51
+ end
52
52
  end
53
-
54
53
  end
55
54
  end