class Sites::GithubRemoteJobs
Constants
- HOST
- JOB_ITEM_SELECTOR
- PATH
- STORE_DIR
Public Class Methods
new()
click to toggle source
# File lib/sites/github_remote_jobs.rb, line 9 def initialize() @url = "#{self.class::HOST}#{self.class::PATH}" @current_time = Time.now @timestamp = @current_time.strftime("%Y%m%d%H%M%S") @doc = Nokogiri::HTML(open_page(@url)) @rows_count = 0 end
Public Instance Methods
collect_companies()
click to toggle source
# File lib/sites/github_remote_jobs.rb, line 17 def collect_companies puts "[Info] Getting the data from #{url}" FileUtils.mkdir_p STORE_DIR CSV.open(filepath, 'w') do |csv| doc.css(JOB_ITEM_SELECTOR).each do |tr| name = tr.search('td')[0].text website = tr.search('td')[1].text region = tr.search('td')[2].text csv << [name, website, region] @rows_count += 1 end end puts "[Done] Collected #{@rows_count} job offers from #{url}. Data stored in: #{filepath}." end
companies_count()
click to toggle source
# File lib/sites/github_remote_jobs.rb, line 33 def companies_count @rows_count end