Class: Crunchbase::Relationship

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

Overview

Superclass for all relationships. Used for both the relationships and providerships arrays on retrieved objects.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Relationship

Returns a new instance of Relationship.



26
27
28
29
# File 'lib/crunchbase/relationship.rb', line 26

def initialize(hash)
  @is_past = hash["is_past"]
  @title = hash["title"]
end

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/crunchbase/relationship.rb', line 6

def title
  @title
end

Class Method Details

.array_from_relationship_list(list) ⇒ Object

Takes a relationship list (directly from the JSON hash) and returns an array of instances of Relationship subclasses.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/crunchbase/relationship.rb', line 10

def self.array_from_relationship_list(list)
  list.map do |l|
    if l["person"]
      PersonRelationship.new(l)
    elsif l["firm"]
      FirmRelationship.new(l)
    elsif l["provider"]
      ProviderRelationship.new(l)
    else
      # "Relationship type not recognized"
      # TODO: Figure out how to log this
      next
    end
  end
end

Instance Method Details

#current?Boolean

Convenience method, returns opposite of is_past?

Returns:

  • (Boolean)


32
33
34
# File 'lib/crunchbase/relationship.rb', line 32

def current?
  !@is_past
end

#is_past?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/crunchbase/relationship.rb', line 36

def is_past?
  @is_past
end