Simplify multiple ifs into single case statement.
This commit is contained in:
parent
732e4438f4
commit
dc21095731
@ -90,10 +90,14 @@ module Cask
|
||||
.returns(T.nilable(T.attached_class))
|
||||
}
|
||||
def self.try_new(ref, warn: false)
|
||||
ref = Pathname(ref) if ref.is_a?(String)
|
||||
return unless ref.is_a?(Pathname)
|
||||
|
||||
path = ref
|
||||
path = case ref
|
||||
when String
|
||||
Pathname(ref)
|
||||
when Pathname
|
||||
ref
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
return if %w[.rb .json].exclude?(path.extname)
|
||||
return unless path.expand_path.exist?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user