Class: Crunchbase::CB_Object

Inherits:
Object
  • Object
show all
Defined in:
lib/crunchbase/cb_object.rb

Overview

Represents any object which can be pulled directly from the CB API.

Constant Summary collapse

ENT_NAME =

Must be overridden in subclasses

"undefined"
ENT_PLURAL =
"undefineds"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject



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

#aliasesObject

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

#tagsObject

Returns an array of tags



11
12
13
# File 'lib/crunchbase/cb_object.rb', line 11

def tags
  @tag_list.respond_to?('split') ? @tag_list.split(', ') : []
end