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))
|
.returns(T.nilable(T.attached_class))
|
||||||
}
|
}
|
||||||
def self.try_new(ref, warn: false)
|
def self.try_new(ref, warn: false)
|
||||||
ref = Pathname(ref) if ref.is_a?(String)
|
path = case ref
|
||||||
return unless ref.is_a?(Pathname)
|
when String
|
||||||
|
Pathname(ref)
|
||||||
path = ref
|
when Pathname
|
||||||
|
ref
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
return if %w[.rb .json].exclude?(path.extname)
|
return if %w[.rb .json].exclude?(path.extname)
|
||||||
return unless path.expand_path.exist?
|
return unless path.expand_path.exist?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user