Class: NetworkProfile::ResearchgateProfile
Class Method Summary
collapse
Instance Method Summary
collapse
all_types, auto_extractor_link_types, #data, #image, #initialize, parse
Class Method Details
.handle?(link) ⇒ Boolean
5
6
7
|
# File 'lib/network_profile/extractors/researchgate_profile.rb', line 5
def self.handle?(link)
link['researchgate.net/profile/']
end
|
Instance Method Details
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/network_profile/extractors/researchgate_profile.rb', line 35
def
card = doc.at(".profile-content-item .nova-c-card")
return {} unless card
items, reads, citations = card.
search(".nova-o-grid__column").
map { |col| col.search('.nova-e-text').map(&:text) }.
map(&:first).map { |i| i.gsub(',', '').to_i }
{ items: items, reads: reads, citations: citations, last_item: last_item }
end
|
#json_ld ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/network_profile/extractors/researchgate_profile.rb', line 9
def json_ld
original = super
if original['@graph']
original['@graph'].first
else
original
end
end
|
#last_item ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/network_profile/extractors/researchgate_profile.rb', line 26
def last_item
item = rdf.find { |_, v| v['type'].to_s['ScholarlyArticle'] }.last
return unless item
title = item.dig('<http://schema.org/headline>', 0)
date = item.dig('<http://schema.org/datePublished>', 0)
"#{title} (#{date})"
end
|
#text ⇒ Object
22
23
24
|
# File 'lib/network_profile/extractors/researchgate_profile.rb', line 22
def text
json_ld.dig('affiliation', 'name') || doc.at('.org')&.text
end
|
#title ⇒ Object
18
19
20
|
# File 'lib/network_profile/extractors/researchgate_profile.rb', line 18
def title
json_ld['name']
end
|