Use Enum.parse

This commit is contained in:
Vitalii Elenhaupt 2019-04-14 19:31:50 +03:00
parent 117e100855
commit f1fe34f8b9
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706

View file

@ -21,16 +21,9 @@ module Ameba
# ```
#
def self.from_name(name : String)
case name.downcase
when "error"
Error
when "warning"
Warning
when "refactoring"
Refactoring
else
raise "Incorrect severity name #{name}. Try one of #{Severity.values}"
end
parse(name)
rescue ArgumentError
raise "Incorrect severity name #{name}. Try one of #{Severity.values}"
end
end