Class: Crunchbase::CBEntity
- Inherits:
-
Object
- Object
- Crunchbase::CBEntity
show all
- Defined in:
- lib/crunchbase/cb_entity.rb
Direct Known Subclasses
Acquisition, BoardMembersAndAdvisor, Category, Competitor, CurrentTeam, Customer, Founder, FundingRound, Headquarter, Image, Investment, Ipo, Location, NewItem, Office, Organization, PastTeam, Person, PrimaryImage, Product, Relationship, SubOrganization, Website
Constant Summary
collapse
- RELATIONSHIPS =
%w[ Crunchbase::Ipo Crunchbase::Product Crunchbase::SubOrganization Crunchbase::FundingRound Crunchbase::Founder Crunchbase::Customer Crunchbase::Competitor Crunchbase::Acquisition ]
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.array_from_list(list) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/crunchbase/cb_entity.rb', line 40
def self.array_from_list(list)
return [] if list.nil?
list['items'].map do |l|
self.new l
end
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
34
35
36
37
38
|
# File 'lib/crunchbase/cb_entity.rb', line 34
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
|
.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.
15
16
17
18
19
|
# File 'lib/crunchbase/cb_entity.rb', line 15
def self.search(options)
return [] unless self == Crunchbase::Organization
return Search.new options, API.search( options, self::RESOURCE_LIST )
end
|
.total_items_from_list(list) ⇒ Object
48
49
50
51
52
|
# File 'lib/crunchbase/cb_entity.rb', line 48
def self.total_items_from_list(list)
return 0 if list.nil?
list['paging']['total_items']
end
|
Instance Method Details
#fetch ⇒ Object
27
28
29
30
31
32
|
# File 'lib/crunchbase/cb_entity.rb', line 27
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
|