Class: NetworkProfile::StackoverflowProfile
- Inherits:
-
DefaultProfile
- Object
- DefaultProfile
- NetworkProfile::StackoverflowProfile
- Defined in:
- lib/network_profile/extractors/stackoverflow_profile.rb
Overview
Constant Summary collapse
- SITES =
[ ["https://stackoverflow.com", "stackoverflow", "Stack Overflow"], ["https://serverfault.com", "serverfault", "Server Fault"], ["https://superuser.com", "superuser", "Super User"], ["https://webapps.stackexchange.com", "webapps", "Web Applications"], ["https://gaming.stackexchange.com", "gaming", "Arqade"], ["https://webmasters.stackexchange.com", "webmasters", "Webmasters"], ["https://cooking.stackexchange.com", "cooking", "Seasoned Advice"], ["https://gamedev.stackexchange.com", "gamedev", "Game Development"], ["https://photo.stackexchange.com", "photo", "Photography"], ["https://stats.stackexchange.com", "stats", "Cross Validated"], ["https://math.stackexchange.com", "math", "Mathematics"], ["https://diy.stackexchange.com", "diy", "Home Improvement"], ["https://gis.stackexchange.com", "gis", "Geographic Information Systems"], ["https://tex.stackexchange.com", "tex", "TeX - LaTeX"], ["https://askubuntu.com", "askubuntu", "Ask Ubuntu"], ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #extra_data ⇒ Object
- #image ⇒ Object
- #site ⇒ Object
- #text ⇒ Object
- #title ⇒ Object
- #user_id ⇒ Object
Methods inherited from DefaultProfile
all_types, auto_extractor_link_types, #data, #initialize, parse
Constructor Details
This class inherits a constructor from NetworkProfile::DefaultProfile
Class Method Details
.handle?(link) ⇒ Boolean
25 26 27 |
# File 'lib/network_profile/extractors/stackoverflow_profile.rb', line 25 def self.handle?(link) SITES.any? { |s, _, _| link.include?(s + "/users/") } end |
Instance Method Details
#extra_data ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/network_profile/extractors/stackoverflow_profile.rb', line 44 def extra_data { reputation: user_api.dig('reputation'), created: Time.at(user_api['creation_date']).to_date, location: user_api.dig('location'), site: site[2], site_logo: "https://cdn.sstatic.net/Sites/#{site[1]}/img/apple-touch-icon.png", tags: .map { |j| [j['tag_name'], j['answer_score'] + j['question_score']] } } end |
#image ⇒ Object
37 38 39 |
# File 'lib/network_profile/extractors/stackoverflow_profile.rb', line 37 def image user_api['profile_image'] end |
#site ⇒ Object
29 30 31 |
# File 'lib/network_profile/extractors/stackoverflow_profile.rb', line 29 def site @site ||= SITES.find { |s, _, _| @link.include?(s) } end |
#text ⇒ Object
41 42 |
# File 'lib/network_profile/extractors/stackoverflow_profile.rb', line 41 def text end |
#title ⇒ Object
33 34 35 |
# File 'lib/network_profile/extractors/stackoverflow_profile.rb', line 33 def title user_api['display_name'] end |
#user_id ⇒ Object
55 56 57 |
# File 'lib/network_profile/extractors/stackoverflow_profile.rb', line 55 def user_id URI.parse(@link).path[%r{/users/(\d+)/?}, 1] end |