Class: Crunchbase::CB_Object
- Inherits:
-
Object
- Object
- Crunchbase::CB_Object
- Defined in:
- lib/crunchbase/cb_object.rb
Overview
Represents any object which can be pulled directly from the CB API.
Direct Known Subclasses
Company, FinancialOrganization, Person, Product, ServiceProvider
Constant Summary collapse
- ENT_NAME =
Must be overridden in subclasses
"undefined"
- ENT_PLURAL =
"undefineds"
Class Method Summary collapse
- .all ⇒ Object
- .find(name) ⇒ Object
-
.get(permalink) ⇒ Object
Factory method to return an instance from a permalink.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Compares two objects, returning true if they have the same permalink (ie, represent the same entity).
-
#aliases ⇒ Object
Returns an array of aliases.
-
#tags ⇒ Object
Returns an array of tags.
Class Method Details
.all ⇒ Object
31 32 33 34 35 36 |
# File 'lib/crunchbase/cb_object.rb', line 31 def self.all all = API.all(self::ENT_PLURAL).map do |ent| ent["namespace"] = self::ENT_NAME EntityListItem.new(ent) end end |
.find(name) ⇒ Object
27 28 29 |
# File 'lib/crunchbase/cb_object.rb', line 27 def self.find(name) get(API.permalink({name: name}, self::ENT_PLURAL)["permalink"]) end |
.get(permalink) ⇒ Object
Factory method to return an instance from a permalink
21 22 23 24 25 |
# File 'lib/crunchbase/cb_object.rb', line 21 def self.get(permalink) j = API.single_entity(permalink, self::ENT_NAME) e = self.new(j) return e end |
Instance Method Details
#===(other) ⇒ Object
Compares two objects, returning true if they have the same permalink (ie, represent the same entity). If you must ensure that the two objects also contain the same data, you should also compare the updated_at attributes.
43 44 45 |
# File 'lib/crunchbase/cb_object.rb', line 43 def ===(other) @permalink == other.permalink end |
#aliases ⇒ Object
Returns an array of aliases
16 17 18 |
# File 'lib/crunchbase/cb_object.rb', line 16 def aliases @alias_list.respond_to?('split') ? @alias_list.split(", ") : [] end |
#tags ⇒ Object
Returns an array of tags
11 12 13 |
# File 'lib/crunchbase/cb_object.rb', line 11 def @tag_list.respond_to?('split') ? @tag_list.split(', ') : [] end |