Class: IndeedMilitaryService
- Inherits:
-
Object
- Object
- IndeedMilitaryService
- Includes:
- IndeedUtilities
- Defined in:
- lib/indeed_military_service.rb
Instance Method Summary collapse
-
#get_military_service ⇒ Object
Return military service info.
-
#initialize(html) ⇒ IndeedMilitaryService
constructor
A new instance of IndeedMilitaryService.
-
#military_branch(mil_item) ⇒ Object
Get military branch.
-
#military_commendations(mil_item) ⇒ Object
Get military commendations.
-
#military_country(mil_item) ⇒ Object
Get country of military service.
-
#military_description(mil_item) ⇒ Object
Get military description.
-
#military_end_date(mil_item) ⇒ Object
Get end date.
-
#military_rank(mil_item) ⇒ Object
Get military rank.
-
#military_start_date(mil_item) ⇒ Object
Get start date.
Methods included from IndeedUtilities
Constructor Details
#initialize(html) ⇒ IndeedMilitaryService
Returns a new instance of IndeedMilitaryService.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/indeed_military_service.rb', line 6 def initialize(html) military_items = html.xpath("//div[contains(concat(' ',normalize-space(@class),' '),' military-section ')]") @military_service = Array.new military_items.each do |mil_item| @military_service.push({ military_country: military_country(mil_item), military_branch: military_branch(mil_item), military_rank: military_rank(mil_item), military_description: military_description(mil_item), military_commendations: military_commendations(mil_item), military_start_date: military_start_date(mil_item), military_end_date: military_end_date(mil_item) }) end end |
Instance Method Details
#get_military_service ⇒ Object
Return military service info
24 25 26 |
# File 'lib/indeed_military_service.rb', line 24 def get_military_service return @military_service end |
#military_branch(mil_item) ⇒ Object
Get military branch
35 36 37 38 |
# File 'lib/indeed_military_service.rb', line 35 def military_branch(mil_item) remove = mil_item.xpath(".//p[@class='military_branch']//span").text mil_item.xpath(".//p[@class='military_branch']").text.gsub(remove, "").strip.lstrip end |
#military_commendations(mil_item) ⇒ Object
Get military commendations
52 53 54 |
# File 'lib/indeed_military_service.rb', line 52 def military_commendations(mil_item) mil_item.xpath(".//p[@class='military_commendations']").text end |
#military_country(mil_item) ⇒ Object
Get country of military service
29 30 31 32 |
# File 'lib/indeed_military_service.rb', line 29 def military_country(mil_item) remove = mil_item.xpath(".//p[@class='military_country']//span").text mil_item.xpath(".//p[@class='military_country']").text.gsub(remove, "").strip.lstrip end |
#military_description(mil_item) ⇒ Object
Get military description
47 48 49 |
# File 'lib/indeed_military_service.rb', line 47 def military_description(mil_item) mil_item.xpath(".//p[@class='military_description']").text end |
#military_end_date(mil_item) ⇒ Object
Get end date
62 63 64 |
# File 'lib/indeed_military_service.rb', line 62 def military_end_date(mil_item) parse_dates(mil_item.xpath(".//p[@class='military_date']").text)[1] end |
#military_rank(mil_item) ⇒ Object
Get military rank
41 42 43 44 |
# File 'lib/indeed_military_service.rb', line 41 def military_rank(mil_item) remove = mil_item.xpath(".//p[@class='military_rank']//span").text mil_item.xpath(".//p[@class='military_rank']").text.gsub(remove, "").strip.lstrip end |
#military_start_date(mil_item) ⇒ Object
Get start date
57 58 59 |
# File 'lib/indeed_military_service.rb', line 57 def military_start_date(mil_item) parse_dates(mil_item.xpath(".//p[@class='military_date']").text)[0] end |