Class: NetworkProfile::UpworkProfile
- Inherits:
-
DefaultProfile
- Object
- DefaultProfile
- NetworkProfile::UpworkProfile
- Defined in:
- lib/network_profile/extractors/upwork_profile.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from DefaultProfile
all_types, auto_extractor_link_types, #data, #image, #initialize, parse
Constructor Details
This class inherits a constructor from NetworkProfile::DefaultProfile
Class Method Details
.handle?(link) ⇒ Boolean
6 7 8 |
# File 'lib/network_profile/extractors/upwork_profile.rb', line 6 def self.handle?(link) link[%r{upwork.com/o/profiles/users/.+}] end |
Instance Method Details
#extra_data ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/network_profile/extractors/upwork_profile.rb', line 27 def extra_data profile = php_vars.dig('profile') rate = profile.dig('stats', 'hourlyRate') { country: profile.dig('profile', 'location').yield_self { |v| "#{v['city']}, #{v['country']}" }, hours: profile.dig('stats', 'totalHours').floor, jobs: profile.dig('stats', 'totalJobsWorked').floor, rating: profile.dig('stats', 'rating').round(2), hourly_rate: "#{rate['amount']} #{rate['currencyCode']}", english_level: profile['stats']['englishLevel'], hire_again: profile.dig('stats', 'hireAgainPercentage'), skills: profile.dig('profile', 'skills').map { |i| i['prettyName'] } } end |
#php_vars ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/network_profile/extractors/upwork_profile.rb', line 18 def php_vars @php_vars ||= begin t = doc.search('script').find { |i| i && i.text['PROFILE_RESPONSE'] }.text t.remove!(/window.PROFILE_RESPONSE=.*summary:/) JSON.parse(t.remove(/\}$/)) end end |
#text ⇒ Object
14 15 16 |
# File 'lib/network_profile/extractors/upwork_profile.rb', line 14 def text doc.at('h2 strong').text end |
#title ⇒ Object
10 11 12 |
# File 'lib/network_profile/extractors/upwork_profile.rb', line 10 def title php_vars.dig('profile', 'profile', 'name') end |