Class: IndeedGroups

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

Instance Method Summary collapse

Methods included from IndeedUtilities

#date_normalize, #parse_dates

Constructor Details

#initialize(html) ⇒ IndeedGroups

Returns a new instance of IndeedGroups.



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

def initialize(html)
  groups = html.xpath("//div[contains(concat(' ',normalize-space(@class),' '),' group-section ')]")
  @group_list = Array.new
  
  groups.each do |group|
    @group_list.push({
                               group_title: group_title(group),
                               group_description: group_description(group),
                               group_start_date: group_start_date(group),
                               group_end_date: group_end_date(group)
    })
  end
end

Instance Method Details

#get_groupsObject

Return group info



21
22
23
# File 'lib/indeed_groups.rb', line 21

def get_groups
  return @group_list
end

#group_description(group) ⇒ Object

Get description of group



31
32
33
# File 'lib/indeed_groups.rb', line 31

def group_description(group)
  group.xpath(".//p[@class='group_description']").text
end

#group_end_date(group) ⇒ Object

Get group end date



41
42
43
# File 'lib/indeed_groups.rb', line 41

def group_end_date(group)
  parse_dates(group.xpath(".//p[@class='group_date']").text)[1]
end

#group_start_date(group) ⇒ Object

Get start date for group



36
37
38
# File 'lib/indeed_groups.rb', line 36

def group_start_date(group)
  parse_dates(group.xpath(".//p[@class='group_date']").text)[0]
end

#group_title(group) ⇒ Object

Get title of group



26
27
28
# File 'lib/indeed_groups.rb', line 26

def group_title(group)
  group.xpath(".//p[@class='group_title']").text
end