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,18 +21,11 @@ module Ameba
# ``` # ```
# #
def self.from_name(name : String) def self.from_name(name : String)
case name.downcase parse(name)
when "error" rescue ArgumentError
Error
when "warning"
Warning
when "refactoring"
Refactoring
else
raise "Incorrect severity name #{name}. Try one of #{Severity.values}" raise "Incorrect severity name #{name}. Try one of #{Severity.values}"
end end
end end
end
# Converter for `YAML.mapping` which converts severity enum to and from YAML. # Converter for `YAML.mapping` which converts severity enum to and from YAML.
class SeverityYamlConverter class SeverityYamlConverter