Class: IndeedLinks

Inherits:
Object
  • Object
show all
Includes:
IndeedUtilities
Defined in:
lib/indeed_links.rb

Instance Method Summary collapse

Methods included from IndeedUtilities

#date_normalize, #parse_dates

Constructor Details

#initialize(html) ⇒ IndeedLinks

Returns a new instance of IndeedLinks.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/indeed_links.rb', line 6

def initialize(html)
  links = html.xpath("//div[contains(concat(' ',normalize-space(@class),' '),' link-section ')]")
  @link_list = Array.new
  
  links.each do |link|
    @link_list.push({
                      link_title: link_title(link),
                      link_url: link_url(link)
    })
  end
end

Instance Method Details

Return person info



19
20
21
# File 'lib/indeed_links.rb', line 19

def get_links
  return @link_list
end

Get title of link



24
25
26
# File 'lib/indeed_links.rb', line 24

def link_title(link)
  link.xpath(".//a").text
end

Get link url



29
30
31
# File 'lib/indeed_links.rb', line 29

def link_url(link)
  link.xpath(".//a").first['href']
end