Class: RelatedPeople

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/related_people.rb

Instance Method Summary collapse

Methods included from Utilities

#is_empty?, #make_list

Constructor Details

#initialize(html) ⇒ RelatedPeople

Returns a new instance of RelatedPeople.



6
7
8
9
# File 'lib/related_people.rb', line 6

def initialize(html)
  @html = html
  parse_related
end

Instance Method Details

Get list of groups



12
13
14
# File 'lib/related_people.rb', line 12

def get_related
  return @related_people_list
end


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/related_people.rb', line 16

def parse_related
  related_people = @html.css(".insights").css(".browse-map").css(".profile-card")

  @related_people_list = Array.new
  related_people.each do |person|
    @related_people_list.push({
                                related_name: related_name(person),
                                related_link: related_link(person),
                                related_person_company: related_person_company(person),
                                related_person_title: related_person_title(person)
                              })
  end
end

Get link to related person’s profile



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

def related_link(person)
  return person.css("h4").css("a")[0]["href"]
end

Get name of related person



31
32
33
# File 'lib/related_people.rb', line 31

def related_name(person)
  return person.css("h4").text
end

Get related person’s company



41
42
43
# File 'lib/related_people.rb', line 41

def related_person_company(person)
  return person.css(".headline").text.split(" at ")[1]
end

Get title of related person



46
47
48
# File 'lib/related_people.rb', line 46

def related_person_title(person)
  return person.css(".headline").text.split(" at ")[0]
end