Class: RIO::RRL::WithPath
- Extended by:
- Fwd
- Includes:
- Error::NotImplemented, PathUtil
- Defined in:
- lib/rio/rrl/withpath.rb,
lib/rio/rrl/withpath.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #absolute? ⇒ Boolean
-
#base ⇒ Object
returns the base of a path.
- #base=(other) ⇒ Object
-
#fspath_no_slash ⇒ Object
The value of fspath() with any trailing slash removed returns a String.
-
#host ⇒ Object
returns the host portion of the URI if their is one otherwise it returns nil returns a String.
- #host=(arg) ⇒ Object
-
#opaque ⇒ Object
returns the portion of the URL starting after the colon following the scheme, and ending before the query portion of the URL returns a String.
-
#openfs_ ⇒ Object
returns an appriate FS object for the scheme.
-
#path ⇒ Object
For RLs that are on the file system this is fspath() For RLs that are remote (http,ftp) this is urlpath() For RLs that have no path this is nil returns a String.
- #path=(arg) ⇒ Object
-
#path_no_slash ⇒ Object
The value of urlpath() with any trailing slash removed returns a String.
- #pathdepth ⇒ Object
-
#pathroot ⇒ Object
returns the portion of the path that when prepended to the path would make it usable.
-
#scheme ⇒ Object
when the URL is legal it is the URI scheme otherwise it is one of Rio’s schemes returns a String.
- #split ⇒ Object
Methods included from Fwd
fwd, fwd_reader, fwd_readers, fwd_writer, fwd_writers
Methods included from Error::NotImplemented
Methods inherited from Base
#==, #===, #=~, #callstr, #close, #initialize, #initialize_copy, #length, parse, #to_s, #url
Constructor Details
This class inherits a constructor from RIO::RRL::Base
Instance Method Details
#absolute? ⇒ Boolean
118 119 120 |
# File 'lib/rio/rrl/withpath.rb', line 118 def absolute? uri.absolute? end |
#base ⇒ Object
returns the base of a path. merging the value returned with this yields the absolute path
85 |
# File 'lib/rio/rrl/withpath.rb', line 85 def base(thebase=nil) nodef(thebase) end |
#base=(other) ⇒ Object
125 126 127 |
# File 'lib/rio/rrl/withpath.rb', line 125 def base=(other) uri.base = other end |
#fspath_no_slash ⇒ Object
The value of fspath() with any trailing slash removed returns a String
103 104 105 |
# File 'lib/rio/rrl/withpath.rb', line 103 def fspath_no_slash() fspath.sub(%r{/*$},'') end |
#host ⇒ Object
returns the host portion of the URI if their is one otherwise it returns nil returns a String
63 |
# File 'lib/rio/rrl/withpath.rb', line 63 def host() nodef() end |
#host=(arg) ⇒ Object
64 |
# File 'lib/rio/rrl/withpath.rb', line 64 def host=(arg) nodef(arg) end |
#opaque ⇒ Object
returns the portion of the URL starting after the colon following the scheme, and ending before the query portion of the URL returns a String
70 |
# File 'lib/rio/rrl/withpath.rb', line 70 def opaque() nodef() end |
#openfs_ ⇒ Object
returns an appriate FS object for the scheme
46 |
# File 'lib/rio/rrl/withpath.rb', line 46 def openfs_() nodef() end |
#path ⇒ Object
For RLs that are on the file system this is fspath() For RLs that are remote (http,ftp) this is urlpath() For RLs that have no path this is nil returns a String
52 |
# File 'lib/rio/rrl/withpath.rb', line 52 def path() nodef{} end |
#path=(arg) ⇒ Object
53 |
# File 'lib/rio/rrl/withpath.rb', line 53 def path=(arg) nodef(arg) end |
#path_no_slash ⇒ Object
The value of urlpath() with any trailing slash removed returns a String
98 99 100 |
# File 'lib/rio/rrl/withpath.rb', line 98 def path_no_slash() path.sub(%r{/*$},'') end |
#pathdepth ⇒ Object
106 107 108 109 |
# File 'lib/rio/rrl/withpath.rb', line 106 def pathdepth() pth = self.path_no_slash pth.count('/') end |
#pathroot ⇒ Object
returns the portion of the path that when prepended to the path would make it usable. For paths on the file system this would be ‘/’ For http and ftp paths it would be host/ For zipfile paths it would be ” For windows paths with a drive it would be ‘C:/’ For windows UNC paths it would be ‘//host/’ returns a String
80 |
# File 'lib/rio/rrl/withpath.rb', line 80 def pathroot() nodef() end |
#scheme ⇒ Object
when the URL is legal it is the URI scheme otherwise it is one of Rio’s schemes returns a String
58 |
# File 'lib/rio/rrl/withpath.rb', line 58 def scheme() nodef() end |
#split ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/rio/rrl/withpath.rb', line 129 def split() u = self.uri.normalize scheme = u.scheme == 'file' ? nil : u.scheme uauth = u. authpart = uauth unless (scheme.nil? and (uauth.nil? || uauth.empty? || uauth == 'localhost')) if u.path.start_with?("/") rootpathpart = "/" pathpart = u.path[1..-1] else pathpart = u.path end pparts = pathpart.split("/") rootpath = ::Alt::URI.create(:scheme => scheme, :authority => authpart, :path => rootpathpart).to_s sparts = [rootpath,pparts].flatten basepart = if rootpath.empty? ::Alt::URI.create(:scheme => 'file', :authority => "", :path => ::Dir.getwd + "/").to_s else rootpath end bparts = [basepart] bparts << basepart.clone (1...sparts.length).each do |n| basepart += sparts[n] + "/" bparts << basepart.clone end if sparts[0].empty? sparts.shift bparts.shift end [sparts,bparts] end |