Class: LawSchoolOutcomes::EmploymentStatusSection

Inherits:
Section
  • Object
show all
Defined in:
lib/law_school_outcomes/employment_summary_report/sections/employment_location_section.rb

Defined Under Namespace

Classes: EmployedNonemployedTotalsError, EmploymentStatusTotalsError

Constant Summary collapse

EMPLOYMENT_STATUSES =
[
  "Employed - Bar Passage Required",
  "Employed - J.D. Advantage",
  "Employed - Professional Position",
  "Employed - Non-Professional Position",
  "Employed - Law School/University Funded",
  "Employed - Undeterminable",
  "Pursuing Graduate Degree Full Time",
  "Unemployed - Start Date Deferred",
  "Unemployed - Not Seeking",
  "Unemployed - Seeking",
  "Employment Status Unknown",
]

Instance Attribute Summary

Attributes inherited from Section

#header_content, #number_of_lines, #report

Instance Method Summary collapse

Methods inherited from Section

#first_line_index, #last_line_index, #lines

Constructor Details

#initialize(report) ⇒ EmploymentStatusSection



22
23
24
25
26
27
28
# File 'lib/law_school_outcomes/employment_summary_report/sections/employment_location_section.rb', line 22

def initialize(report)
  super({
    :report => report,
    :header_content => "EMPLOYMENT STATUS",
    :number_of_lines => EMPLOYMENT_STATUSES.count + 1 + 1 # consider right-sizing until the index of the last row: "Total Graduates"
  })
end

Instance Method Details

#resultsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/law_school_outcomes/employment_summary_report/sections/employment_location_section.rb', line 34

def results
  counts = []

  EMPLOYMENT_STATUSES.each do |status|
    line = lines.find{|line| line.include?(status) }
    number = line ? last_number(line) : 0
    counts << {status: status, count: number}
  end

  calculated_total_graduates = counts.map{|h| h[:count] }.reduce{|sum, x| sum + x}
  raise EmploymentStatusTotalsError unless calculated_total_graduates == total_graduates

  employed_statuses = EMPLOYMENT_STATUSES.select{|status| status.include?("Employed - ")}
  nonemployed_statuses = EMPLOYMENT_STATUSES.select{|status| !status.include?("Employed - ")}
  employed_count = counts.select{|h| employed_statuses.include?(h[:status]) }.map{|h| h[:count] }.reduce{|sum, x| sum + x}
  nonemployed_count = counts.select{|h| nonemployed_statuses.include?(h[:status]) }.map{|h| h[:count] }.reduce{|sum, x| sum + x}
  raise EmployedNonemployedTotalsError if employed_count + nonemployed_count != total_graduates

  return counts
end

#total_graduatesObject



30
31
32
# File 'lib/law_school_outcomes/employment_summary_report/sections/employment_location_section.rb', line 30

def total_graduates
  last_number(lines.last)
end