You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sqm-dashboards/app/models/employment.rb

40 lines
1.1 KiB

class Employment < ApplicationRecord
scope :by_designation, -> { all.map { |employment| [employment.designation, employment] }.to_h }
def self.to_designation(employment)
return "Unknown" if employment.blank? || employment.nil?
case employment
in /^1$|^1100$/i
"Two adults with full-time employment"
in /^2$|^2100$/i
"One adult with full-time employment"
in /^3$|^3100$/i
"Two adults with part-time employment"
in /^4$|^4100$/i
"One adult with part-time employment"
in /^5$|^5100$/i
"No full-time or part-time employment"
in /^99$|^100$|^99100$/i
"Unknown"
else
puts "************************************"
puts "******** ERROR **********"
puts ""
puts "Error parsing Employment column. '#{employment}' is not a known value. Halting execution"
puts ""
puts "************************************"
exit
end
end
def points
higher_level_employment = ["Two adults with full-time employment", "One adult with full-time employment"]
if higher_level_employment.include?(designation)
1
else
0
end
end
end