Class: IndeedJobs
- Inherits:
-
Object
- Object
- IndeedJobs
- Includes:
- IndeedUtilities
- Defined in:
- lib/indeed_jobs.rb
Instance Method Summary collapse
-
#company(job) ⇒ Object
Get company.
-
#company_location(job) ⇒ Object
Get work location.
-
#end_date(job) ⇒ Object
Get end date.
-
#get_jobs ⇒ Object
Return job info.
-
#initialize(html) ⇒ IndeedJobs
constructor
A new instance of IndeedJobs.
-
#job_description(job) ⇒ Object
Get job description.
-
#job_title(job) ⇒ Object
Get job title.
-
#start_date(job) ⇒ Object
Get start date.
Methods included from IndeedUtilities
Constructor Details
#initialize(html) ⇒ IndeedJobs
Returns a new instance of IndeedJobs.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/indeed_jobs.rb', line 6 def initialize(html) @html = Nokogiri::HTML(html) jobs = @html.xpath("//div[contains(concat(' ',normalize-space(@class),' '),' work-experience-section ')]") @job_info = Array.new jobs.each do |job| @job_info.push({ job_title: job_title(job), company: company(job), company_location: company_location(job), job_description: job_description(job), start_date: start_date(job), end_date: end_date(job) }) end end |
Instance Method Details
#company(job) ⇒ Object
Get company
35 36 37 |
# File 'lib/indeed_jobs.rb', line 35 def company(job) job.xpath(".//div[@class='work_company']//span").first.text end |
#company_location(job) ⇒ Object
Get work location
40 41 42 |
# File 'lib/indeed_jobs.rb', line 40 def company_location(job) job.xpath(".//div[@class='work_company']//div[@class='inline-block']//span").text end |
#end_date(job) ⇒ Object
Get end date
55 56 57 |
# File 'lib/indeed_jobs.rb', line 55 def end_date(job) parse_dates(job.xpath(".//p[@class='work_dates']").text)[1] end |
#get_jobs ⇒ Object
Return job info
25 26 27 |
# File 'lib/indeed_jobs.rb', line 25 def get_jobs return @job_info end |
#job_description(job) ⇒ Object
Get job description
45 46 47 |
# File 'lib/indeed_jobs.rb', line 45 def job_description(job) job.xpath(".//p[@class='work_description']").text end |
#job_title(job) ⇒ Object
Get job title
30 31 32 |
# File 'lib/indeed_jobs.rb', line 30 def job_title(job) job.xpath(".//p[@class='work_title title']").text end |
#start_date(job) ⇒ Object
Get start date
50 51 52 |
# File 'lib/indeed_jobs.rb', line 50 def start_date(job) parse_dates(job.xpath(".//p[@class='work_dates']").text)[0] end |