class LawSchoolOutcomes::EmploymentStatusSection
Constants
- EMPLOYMENT_STATUSES
Public Class Methods
new(report)
click to toggle source
Calls superclass method
LawSchoolOutcomes::Section::new
# 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
Public Instance Methods
results()
click to toggle source
# 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_graduates()
click to toggle source
# File lib/law_school_outcomes/employment_summary_report/sections/employment_location_section.rb, line 30 def total_graduates last_number(lines.last) end