Class: Sites::JobsRails42
Constant Summary collapse
- HOST =
@NOTE: I had to rename this class because we are not allowed to have numbers on the beginning of the class name (42JobsRails won’t work). file paths follow this convention
'https://www.42jobs.io'.freeze
- PATH =
'/rails/jobs-remote'.freeze
- JOB_ITEM_SELECTOR =
'li.job-offers__item a'.freeze
- STORE_DIR =
'data/jobs_rails42'.freeze
Instance Attribute Summary
Attributes inherited from Base
#doc, #jobs_count, #rows_count, #url
Instance Method Summary collapse
- #collect_jobs(limit: nil) ⇒ Object
-
#initialize ⇒ JobsRails42
constructor
A new instance of JobsRails42.
Constructor Details
#initialize ⇒ JobsRails42
Returns a new instance of JobsRails42.
13 14 15 16 17 18 19 20 21 |
# File 'lib/sites/jobs_rails42.rb', line 13 def initialize @url = "#{self.class::HOST}#{self.class::PATH}" @current_time = Time.now @timestamp = @current_time.strftime("%Y%m%d%H%M%S") @doc = nil @total_pages = 4 @rows_count = 0 @jobs_count = get_jobs_count end |
Instance Method Details
#collect_jobs(limit: nil) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/sites/jobs_rails42.rb', line 23 def collect_jobs(limit: nil) FileUtils.mkdir_p STORE_DIR (1..@total_pages).each do |page| process_page(page: page, limit: limit) end end |