Sha256: 0fa421724f1e9372597d169656753ec59cc4953a464beb4544a815c9b3c3c259
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'open-uri' require 'nokogiri' ## # Module for parsing Linode employee info module Linodians DATA_URL = 'https://www.linode.com/employees' PHOTO_URL = 'https://www.linode.com/media/images/employees/%s.png' class << self ## # Insert a helper .new() method for creating a new Group object def new(*args) self::Group.new(*args) end def download_data Nokogiri::HTML(open(DATA_URL)).css('.employee-display').map do |block| data = parse_user(block).merge parse_social(block) Employee.new data end end private def parse_user(block) { username: block.at_css('img')['img-name'], fullname: block.at_css('strong').text, title: block.at_css('small').text } end def parse_social(block) block.css('a.employee-link').map do |link| # Social site name from CSS class, link target [link[:class].split.last.split('-').last.to_sym, link['href']] end.to_h end end end require 'linodians/employee' require 'linodians/group'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
linodians-0.0.2 | lib/linodians.rb |