here is the goal:

i've an Array of Unix pathes :
forbidden = ["/Volumes/U3 System",
             "/Volumes/EMTEC KEY/emtec_dl",
             "/Volumes/EMTEC KEY/emtec_dl/Win98SE new driver.exe",
             "/Volumes/EMTEC KEY/emtec_dl/v233r001"
            ]

i want to forbid access to those pathes BUT since, for example,
"/Volumes/EMTEC KEY/emtec_dl/Win98SE new driver.exe" belongs ¥µ
to the path (it's below this path) "/Volumes/EMTEC KEY/emtec_dl"
it is unusefull to have it in the Array.

in the case above i'd like to return :

forbidden = ["/Volumes/U3 System",
             "/Volumes/EMTEC KEY/emtec_dl"
            ]

what i've done :


class Array
   def includePath?(path)
     self.each { | x |
       return true if path.startsWith?(x)
     }
     return false
   end
   def getContainers!
     self.delete_if { | x | ( self - [ x ] ).includePath?( x ) }
   end
end

class String
  def startsWith?(dir)
    self.index(dir) === 0
  end
end

then forbidden.getContainers! gives me the expected result.

what do you think about this solution ?
could you propose a better one ?

also, because english isn't my mother tongue, are my methods naming
correct ?

-- 
Une Bñ×ue