brew-doctor: use String.start_with?

This commit is contained in:
Adam Vandenberg 2011-06-13 14:32:50 -07:00
parent e6bac8a8ea
commit cee1003782

View File

@ -17,7 +17,7 @@ class Volumes
def which path def which path
@volumes.each_index do |i| @volumes.each_index do |i|
vol = @volumes[i] vol = @volumes[i]
return i if is_prefix?(vol[1], path) return i if vol[1].start_with? path.to_s
end end
return -1 return -1
@ -25,12 +25,6 @@ class Volumes
end end
def is_prefix? prefix, longer_string
p = prefix.to_s
longer_string.to_s[0,p.length] == p
end
def remove_trailing_slash s def remove_trailing_slash s
(s[s.length-1] == '/') ? s[0,s.length-1] : s (s[s.length-1] == '/') ? s[0,s.length-1] : s
end end