class Class
def _def(name, &_fn)
define_method(name, &_fn)
return self
end
end
allMask = "*"
String._def(:pathParts) {
ret = self.split(/[\\\/]/, -1)
if(ret.size > 0 && ret[ret.size - 1] == allMask)
ret[0 ... ret.size - 1]
else
ret
end
}
p "a/b".pathParts
Y2xhc3MgQ2xhc3MKICBkZWYgX2RlZihuYW1lLCAmX2ZuKQogICAgZGVmaW5lX21ldGhvZChuYW1lLCAmX2ZuKQogICAgcmV0dXJuIHNlbGYKICBlbmQKZW5kCgphbGxNYXNrID0gIioiClN0cmluZy5fZGVmKDpwYXRoUGFydHMpIHsKICByZXQgPSBzZWxmLnNwbGl0KC9bXFxcL10vLCAtMSkKICBpZihyZXQuc2l6ZSA+IDAgJiYgcmV0W3JldC5zaXplIC0gMV0gPT0gYWxsTWFzaykKICAgIHJldFswIC4uLiByZXQuc2l6ZSAtIDFdCiAgZWxzZQogICAgcmV0CiAgZW5kCn0KCnAgImEvYiIucGF0aFBhcnRz