fork download
  1. class Class
  2. def _def(name, &_fn)
  3. define_method(name, &_fn)
  4. return self
  5. end
  6. end
  7.  
  8. allMask = "*"
  9. String._def(:pathParts) {
  10. ret = self.split(/[\\\/]/, -1)
  11. if(ret.size > 0 && ret[ret.size - 1] == allMask)
  12. ret[0 ... ret.size - 1]
  13. else
  14. ret
  15. end
  16. }
  17.  
  18. p "a/b".pathParts
Success #stdin #stdout 0.02s 7456KB
stdin
Standard input is empty
stdout
["a", "b"]