Class: PersonalInfo
Instance Method Summary collapse
-
#area ⇒ Object
Get country/state.
-
#causes ⇒ Object
Get causes they care about.
-
#certifications ⇒ Object
Get the person’s certifications.
-
#education ⇒ Object
Get education info.
-
#first_name ⇒ Object
Get first part of name.
-
#full_html ⇒ Object
Save the full html of the page.
-
#full_location ⇒ Object
Get full location.
-
#full_name ⇒ Object
Get the full name of the person.
-
#get_personal_info ⇒ Object
Return person hash.
-
#groups ⇒ Object
Get a list of groups they are in.
-
#industry ⇒ Object
Get the industry the person works in (2 different formats).
-
#initialize(profile, profile_url) ⇒ PersonalInfo
constructor
A new instance of PersonalInfo.
-
#interests ⇒ Object
Get list of interests.
-
#languages ⇒ Object
Get a list of languages they speak.
-
#last_name ⇒ Object
Get last part of name.
-
#location ⇒ Object
Get town.
-
#number_of_connections ⇒ Object
Get the number of connections.
-
#related_people ⇒ Object
Get the people also viewed list from the side.
-
#skills ⇒ Object
Get list of skills.
-
#summary ⇒ Object
Get the summary field (2 different formats).
-
#title ⇒ Object
Get the overall/current title.
Methods included from Utilities
Constructor Details
#initialize(profile, profile_url) ⇒ PersonalInfo
Returns a new instance of PersonalInfo.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/personal_info.rb', line 12 def initialize(profile, profile_url) @profile = profile @html = Nokogiri::HTML(profile) @profile_url = profile_url # Parse attributes p = Picture.new(@html) @personal_info = { profile_url: @profile_url, full_name: full_name, first_name: first_name, last_name: last_name, skills: skills, full_location: full_location, location: location, area: area, industry: industry, summary: summary, current_title: title, interests: interests, education: education, groups: groups, causes: causes, certifications: certifications, languages: languages, related_people: , number_of_connections: number_of_connections, picture: p.picture, pic_path: p.pic_path, full_html: full_html} end |
Instance Method Details
#area ⇒ Object
Get country/state
131 132 133 |
# File 'lib/personal_info.rb', line 131 def area full_location.split(",").last.strip if !full_location.empty? end |
#causes ⇒ Object
Get causes they care about
79 80 81 82 |
# File 'lib/personal_info.rb', line 79 def causes c = Causes.new(@html) return c.get_causes end |
#certifications ⇒ Object
Get the person’s certifications
85 86 87 88 |
# File 'lib/personal_info.rb', line 85 def certifications c = Certifications.new(@html) return c.get_certifications end |
#education ⇒ Object
Get education info
67 68 69 70 |
# File 'lib/personal_info.rb', line 67 def education e = Education.new(@html) return e.get_education end |
#first_name ⇒ Object
Get first part of name
57 58 59 |
# File 'lib/personal_info.rb', line 57 def first_name full_name.split(" ", 2).first.strip end |
#full_html ⇒ Object
Save the full html of the page
176 177 178 |
# File 'lib/personal_info.rb', line 176 def full_html @profile end |
#full_location ⇒ Object
Get full location
121 122 123 |
# File 'lib/personal_info.rb', line 121 def full_location @html.css('.profile-overview').css('.locality').text end |
#full_name ⇒ Object
Get the full name of the person
50 51 52 53 54 |
# File 'lib/personal_info.rb', line 50 def full_name name = @html.css(".profile-overview").css('h1') name = @html.css(".profile-overview-content").css('h1') if is_empty?(name) return name.text end |
#get_personal_info ⇒ Object
Return person hash
45 46 47 |
# File 'lib/personal_info.rb', line 45 def get_personal_info return @personal_info end |
#groups ⇒ Object
Get a list of groups they are in
73 74 75 76 |
# File 'lib/personal_info.rb', line 73 def groups g = Groups.new(@html) return g.get_groups end |
#industry ⇒ Object
Get the industry the person works in (2 different formats)
136 137 138 139 140 |
# File 'lib/personal_info.rb', line 136 def industry industry = @html.css('.profile-overview').css('.descriptor')[1] industry = @html.css('.profile-overview').css('.industry') if is_empty?(industry) return industry.text end |
#interests ⇒ Object
Get list of interests
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/personal_info.rb', line 163 def interests interest_list = Array.new interests = @html.css('#interests').css('.interest') interests = @html.css('#background-interests').css('.interest-item') if is_empty?(interests) interests.each do |interest| interest_list.push(interest.text) end return interest_list end |
#languages ⇒ Object
Get a list of languages they speak
91 92 93 94 |
# File 'lib/personal_info.rb', line 91 def languages l = Languages.new(@html) return l.get_languages end |
#last_name ⇒ Object
Get last part of name
62 63 64 |
# File 'lib/personal_info.rb', line 62 def last_name full_name.split(" ", 2).last.strip end |
#location ⇒ Object
Get town
126 127 128 |
# File 'lib/personal_info.rb', line 126 def location full_location.split(",").first.strip if !full_location.empty? end |
#number_of_connections ⇒ Object
Get the number of connections
158 159 160 |
# File 'lib/personal_info.rb', line 158 def number_of_connections @html.css('.member-connections')[0].text.gsub("connections", "").strip end |
#related_people ⇒ Object
Get the people also viewed list from the side
97 98 99 100 |
# File 'lib/personal_info.rb', line 97 def r = RelatedPeople.new(@html) return r. end |
#skills ⇒ Object
Get list of skills
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/personal_info.rb', line 103 def skills skill_list = Array.new # Two formatting options for skills skills = @html.css('#skills').css('.skill') skills = @html.css('.skill-pill .endorse-item-name-text') if is_empty?(skills) # Make list of skills (not including see more or less) skills.each do |skill| if !skill["class"].include?("see-more") && !skill["class"].include?("see-less") skill_list.push(skill.text) end end return skill_list end |
#summary ⇒ Object
Get the summary field (2 different formats)
143 144 145 146 147 |
# File 'lib/personal_info.rb', line 143 def summary summary = @html.css('#summary').css('.description') summary = @html.css('.summary').first if is_empty?(summary) return summary.text if summary end |
#title ⇒ Object
Get the overall/current title
150 151 152 153 154 155 |
# File 'lib/personal_info.rb', line 150 def title title = @html.css('.title').css('.headline') title = @html.css('#headline').css('.title') if is_empty?(title) title = @html.css('.title') if is_empty?(title) return title.text end |