lib/rio/rl/pathmethods.rb in rio-0.3.7 vs lib/rio/rl/pathmethods.rb in rio-0.3.8

- old
+ new

@@ -1,8 +1,8 @@ #-- # =============================================================================== -# Copyright (c) 2005, Christopher Kleckner +# Copyright (c) 2005, 2006 Christopher Kleckner # All rights reserved # # This file is part of the Rio library for ruby. # # Rio is free software; you can redistribute it and/or modify @@ -20,11 +20,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # =============================================================================== #++ # # To create the documentation for Rio run the command -# rake rdoc +# ruby build_doc.rb # from the distribution directory. Then point your browser at the 'doc/rdoc' directory. # # Suggested Reading # * RIO::Doc::SYNOPSIS # * RIO::Doc::INTRO @@ -50,10 +50,14 @@ ur = self.urlroot.sub(/#{pr}$/,'') up = self.urlpath.sub(/^#{pr}/,'') [ur,pr,up] end + def pathdepth() + pth = self.path_no_slash + (pth == '/' ? 0 : pth.count('/')) + end def split() if absolute? parts = self._parts sparts = [] sparts << parts[0] + parts[1] @@ -72,10 +76,11 @@ def join(*args) return self if args.empty? sa = args.map { |arg| ::URI.escape(arg.to_s,ESCAPE) } sa.unshift(self.urlpath) unless self.urlpath.empty? self.urlpath = sa.join('/').squeeze('/') + self end def parse_url(str) ::URI.parse(::URI.escape(str,ESCAPE)) end @@ -87,9 +92,14 @@ self.class.new(uri.route_to(other.uri),{:base => self.url}) end def merge(other) self.class.new(uri.merge(other.uri)) end + + def dirname() + ::File.dirname(self.path_no_slash) + end + end end end