Class: Crunchbase::CBEntity
- Inherits:
-
Object
- Object
- Crunchbase::CBEntity
show all
- Defined in:
- lib/crunchbase/cb_entity.rb
Direct Known Subclasses
Acquisition, AdvisorAt, BoardMembersAndAdvisor, Category, Competitor, CurrentTeam, Customer, Degree, Experience, FoundedCompany, Founder, FundingRound, Headquarter, Image, Investment, Ipo, Location, NewItem, Office, Organization, OrganizationInvestor, PastTeam, Person, PrimaryAffiliation, PrimaryImage, PrimaryLocation, Product, Relationship, SubOrganization, Video, Website
Constant Summary
collapse
- RELATIONSHIPS =
%w[ Crunchbase::Ipo Crunchbase::Product Crunchbase::SubOrganization Crunchbase::FundingRound Crunchbase::Founder Crunchbase::Customer Crunchbase::Competitor Crunchbase::Acquisition Crunchbase::Degree Crunchbase::PrimaryAffiliation Crunchbase::Experience, Crunchbase::FoundedCompany Crunchbase::Video Crunchbase::PrimaryLocation Crunchbase::AdvisorAt Crunchbase::OrganizationInvestor ]
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.array_from_list(list) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/crunchbase/cb_entity.rb', line 52
def self.array_from_list(list)
return [] if list.nil?
list['items'].map do |l|
self.new l if l.kind_of?(Hash)
end.compact
end
|
.category_lists_by_permalink(permalink, classify_name, options = {}) ⇒ Object
33
34
35
36
37
|
# File 'lib/crunchbase/cb_entity.rb', line 33
def self.category_lists_by_permalink(permalink, classify_name, options={})
options[:model_name] = (RELATIONSHIPS.include?(self.name) ? Relationship : self)
return API.lists_for_category(classify_name, permalink, self::RESOURCE_LIST, options)
end
|
.get(permalink) ⇒ Object
Factory method to return an instance from a permalink
9
10
11
|
# File 'lib/crunchbase/cb_entity.rb', line 9
def self.get(permalink)
return self.new( API.single_entity(permalink, self::RESOURCE_NAME) )
end
|
.list(page = nil) ⇒ Object
46
47
48
49
50
|
# File 'lib/crunchbase/cb_entity.rb', line 46
def self.list(page=nil)
options = { page: page, model_name: self }
return API.list( options, self::RESOURCE_LIST )
end
|
.lists_for_permalink(permalink, options = {}) ⇒ Object
21
22
23
24
25
|
# File 'lib/crunchbase/cb_entity.rb', line 21
def self.lists_for_permalink(permalink, options={})
options[:model_name] = (RELATIONSHIPS.include?(self.name) ? Relationship : self)
return API.lists_for_permalink(permalink, self::RESOURCE_LIST, options)
end
|
.lists_for_person_permalink(permalink, options = {}) ⇒ Object
27
28
29
30
31
|
# File 'lib/crunchbase/cb_entity.rb', line 27
def self.lists_for_person_permalink(permalink, options={})
options[:model_name] = (RELATIONSHIPS.include?(self.name) ? Relationship : self)
return API.lists_for_person_permalink(permalink, self::RESOURCE_LIST, options)
end
|
.parsing_from_list(list) ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/crunchbase/cb_entity.rb', line 60
def self.parsing_from_list(list)
return [] if list.nil?
list.map do |l|
self.new l if l.kind_of?(Hash)
end.compact
end
|
.search(options) ⇒ Object
Finds an entity by its name. Uses two HTTP requests; one to find the permalink, and another to request the actual entity.
.total_items_from_list(list) ⇒ Object
68
69
70
71
72
|
# File 'lib/crunchbase/cb_entity.rb', line 68
def self.total_items_from_list(list)
return 0 if list.nil?
list['paging']['total_items']
end
|
Instance Method Details
#fetch ⇒ Object
39
40
41
42
43
44
|
# File 'lib/crunchbase/cb_entity.rb', line 39
def fetch
fetch_object = get_fetch_object
return [] if fetch_object.empty?
return fetch_object[0].new API.fetch(self.permalink, fetch_object[1])
end
|