Class: LawSchoolOutcomes::EmploymentLocationSection
- Defined in:
- lib/law_school_outcomes/employment_summary_report/sections/employment_status_section.rb
Constant Summary collapse
- LOCATION_TYPES =
[ "State - Largest Employment", "State - 2nd Largest Employment", "State - 3rd Largest Employment", "Employed in Foreign Countries" ]
- STATE_TYPES =
LOCATION_TYPES.select{|location_type| location_type.include?("State - ")}
- FOREIGN_TYPE =
"Employed in Foreign Countries"
Instance Attribute Summary
Attributes inherited from Section
#header_content, #number_of_lines, #report
Instance Method Summary collapse
-
#initialize(report) ⇒ EmploymentLocationSection
constructor
A new instance of EmploymentLocationSection.
- #results ⇒ Object
Methods inherited from Section
#first_line_index, #last_line_index, #lines
Constructor Details
#initialize(report) ⇒ EmploymentLocationSection
14 15 16 17 18 19 20 |
# File 'lib/law_school_outcomes/employment_summary_report/sections/employment_status_section.rb', line 14 def initialize(report) super({ :report => report, :header_content => "EMPLOYMENT LOCATION", :number_of_lines => LOCATION_TYPES.count + 1 # includes header line }) end |
Instance Method Details
#results ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/law_school_outcomes/employment_summary_report/sections/employment_status_section.rb', line 22 def results counts = [] STATE_TYPES.each do |state_type| line = lines.find{|line| line.include?(state_type) } state_and_count = line.gsub(state_type,"").strip.split(" ").select{|str| !str.empty?}.map{|str| str.strip } counts << {type: state_type, location: state_and_count.first, count: state_and_count.last} end foreign_line = lines.find{|line| line.include?(FOREIGN_TYPE) } foreign_count = last_number(foreign_line) counts << {type: FOREIGN_TYPE, location: FOREIGN_TYPE, count: foreign_count} return counts end |