Browse Source

Refactor ecstat age check

pull/619/head
baarkerlounger 3 years ago
parent
commit
048db88d47
  1. 8
      app/models/case_log.rb

8
app/models/case_log.rb

@ -475,14 +475,18 @@ private
end end
end end
(2..8).each do |idx| (2..8).each do |idx|
if public_send("age#{idx}") && public_send("age#{idx}") < 16 if age_under_16?(idx)
self["ecstat#{idx}"] = 9 self["ecstat#{idx}"] = 9
elsif public_send("ecstat#{idx}") == 9 && (public_send("age#{idx}").nil? || public_send("age#{idx}") >= 16) && age_known?(idx) elsif public_send("ecstat#{idx}") == 9 && age_known?(idx)
self["ecstat#{idx}"] = nil self["ecstat#{idx}"] = nil
end end
end end
end end
def age_under_16?(person_num)
public_send("age#{person_num}") && public_send("age#{person_num}") < 16
end
def age_known?(person_num) def age_known?(person_num)
!!public_send("age#{person_num}_known")&.zero? !!public_send("age#{person_num}_known")&.zero?
end end

Loading…
Cancel
Save