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.
33 lines
735 B
33 lines
735 B
class Benefit < ApplicationRecord
|
|
scope :by_designation, -> { all.map { |benefits| [benefits.designation, benefits] }.to_h }
|
|
|
|
def self.to_designation(benefits)
|
|
return "Unknown" if benefits.blank? or benefits.nil?
|
|
|
|
case benefits
|
|
in /^1$/i
|
|
"Yes"
|
|
in /^2$/i
|
|
"No"
|
|
in /^3$/i
|
|
"Unknown"
|
|
in /^99$|^100$/i
|
|
"Unknown"
|
|
else
|
|
puts "************************************"
|
|
puts "******** ERROR **********"
|
|
puts ""
|
|
puts "Error parsing benefits column. '#{benefits}' is not a known value. Halting execution"
|
|
puts ""
|
|
puts "************************************"
|
|
exit
|
|
end
|
|
end
|
|
|
|
def points
|
|
return 1 if designation == "No"
|
|
|
|
0
|
|
end
|
|
end
|