Class: NetworkProfile::DefaultProfile
- Inherits:
-
Object
- Object
- NetworkProfile::DefaultProfile
show all
- Includes:
- ActiveSupport::DescendantsTracker
- Defined in:
- lib/network_profile/extractors/default_profile.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of DefaultProfile.
42
43
44
|
# File 'lib/network_profile/extractors/default_profile.rb', line 42
def initialize(link)
@link = link
end
|
Class Attribute Details
Returns the value of attribute headers.
14
15
16
|
# File 'lib/network_profile/extractors/default_profile.rb', line 14
def
@headers
end
|
.mdi_icon ⇒ Object
Returns the value of attribute mdi_icon.
13
14
15
|
# File 'lib/network_profile/extractors/default_profile.rb', line 13
def mdi_icon
@mdi_icon
end
|
Class Method Details
.all_types ⇒ Object
31
32
33
|
# File 'lib/network_profile/extractors/default_profile.rb', line 31
def self.all_types
+ [NetworkProfile::Custom]
end
|
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/network_profile/extractors/default_profile.rb', line 17
def self.
[
NetworkProfile::GithubProfile,
NetworkProfile::GithubProject,
NetworkProfile::LinkedinProfile,
NetworkProfile::InstagramProfile,
NetworkProfile::XingProfile,
NetworkProfile::ResearchgateProfile,
NetworkProfile::UpworkProfile,
NetworkProfile::FacebookProfile,
NetworkProfile::StackoverflowProfile,
].freeze
end
|
.parse(link, include_fallback_custom: false) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/network_profile/extractors/default_profile.rb', line 35
def self.parse(link, include_fallback_custom: false)
link_type = (include_fallback_custom ? all_types : ).find { |i| i.handle?(link) }
if link_type
link_type.new(link.strip).data
end
end
|
Instance Method Details
#data ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/network_profile/extractors/default_profile.rb', line 62
def data
{
site_icon: self.class.mdi_icon,
link: @link,
title: title,
text: text,
image: image,
type: self.class.name.underscore.split('/').last
}.merge()
end
|
73
74
75
|
# File 'lib/network_profile/extractors/default_profile.rb', line 73
def
{}
end
|
#image ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/network_profile/extractors/default_profile.rb', line 46
def image
img = doc.at('meta[property=og\:image]')&.[]('content')
if img && img[%r{^/\w+}]
img = URI.join(@link, img).to_s
end
img
end
|
#text ⇒ Object
58
59
60
|
# File 'lib/network_profile/extractors/default_profile.rb', line 58
def text
doc.at('meta[property=og\:description]')&.[]('content') || doc.at('meta[name=description]')&.[]('content')
end
|
#title ⇒ Object
54
55
56
|
# File 'lib/network_profile/extractors/default_profile.rb', line 54
def title
doc.at('title')&.text
end
|