Class: Sovren::Military

Inherits:
Object
  • Object
show all
Defined in:
lib/sovren/military.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



3
4
5
# File 'lib/sovren/military.rb', line 3

def branch
  @branch
end

#country_servedObject

Returns the value of attribute country_served.



3
4
5
# File 'lib/sovren/military.rb', line 3

def country_served
  @country_served
end

#discharge_statusObject

Returns the value of attribute discharge_status.



3
4
5
# File 'lib/sovren/military.rb', line 3

def discharge_status
  @discharge_status
end

#end_dateObject

Returns the value of attribute end_date.



3
4
5
# File 'lib/sovren/military.rb', line 3

def end_date
  @end_date
end

#rank_achievedObject

Returns the value of attribute rank_achieved.



3
4
5
# File 'lib/sovren/military.rb', line 3

def rank_achieved
  @rank_achieved
end

#recognition_achievedObject

Returns the value of attribute recognition_achieved.



3
4
5
# File 'lib/sovren/military.rb', line 3

def recognition_achieved
  @recognition_achieved
end

#start_dateObject

Returns the value of attribute start_date.



3
4
5
# File 'lib/sovren/military.rb', line 3

def start_date
  @start_date
end

Class Method Details

.parse(military_history) ⇒ Object



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

def self.parse(military_history)
  return nil if military_history.nil?
  e = Military.new
  e.country_served = military_history.css('CountryServed').text
  e.branch = military_history.css('ServiceDetail').first['branch']
  e.rank_achieved = military_history.css('ServiceDetail RankAchieved CurrentOrEndRank').text
  e.recognition_achieved = military_history.css('ServiceDetail RecognitionAchieved').text
  e.discharge_status = military_history.css('ServiceDetail DischargeStatus').text
  e.start_date = Date.parse(military_history.css('DatesOfService StartDate AnyDate').text) rescue nil
  e.end_date = Date.parse(military_history.css('DatesOfService EndDate AnyDate').text) rescue nil
  e
end