Classes

Methods

Files

In Files

Modules

Namespaces

Files

  • README

Class Index

  • RIO
  • RIO::Doc
  • RIO::Doc::EXAMPLES
  • RIO::Doc::HOWTO
  • RIO::Doc::INDEX
  • RIO::Doc::INTRO
  • RIO::Doc::OPTIONAL
  • RIO::Doc::SYNOPSIS
  • RIO::IF
  • RIO::IF::CSV
  • RIO::IF::Dir
  • RIO::IF::File
  • RIO::IF::FileOrDir
  • RIO::IF::Grande
  • RIO::IF::GrandeEntry
  • RIO::IF::GrandeStream
  • RIO::IF::Path
  • RIO::IF::RubyIO
  • RIO::IF::String
  • RIO::IF::Test
  • RIO::IF::YAML
  • RIO::Rio
  • Kernel
No matching classes.

Methods

  • #/
  • #abs
  • #base
  • #basename
  • #basename=
  • #cleanpath
  • #dirname
  • #dirname=
  • #expand_path
  • #ext
  • #ext?
  • #extname
  • #extname=
  • #filename
  • #filename=
  • #fspath
  • #host
  • #join
  • #join!
  • #merge
  • #noext
  • #opaque
  • #path
  • #realpath
  • #rel
  • #route_from
  • #route_to
  • #scheme
  • #splitpath
  • #to_uri
  • #to_url
  • #urlpath

In Files

  • lib/rio/if/path.rb
module

RIO::IF::Path

rel_prefix: (../..)

Public Instance Methods

/(arg) click to toggle source

Subdirectory operator.

Effectively the same as #join(arg)

  a = rio('a')
  b = rio('b')
  c = a/b                   #=> rio('a/b')

  ario = rio('adir')
  ario/'afile.rb'           #=> rio('adir/afile.rb')
  ario/'b'/'c'/'d'          #=> rio('adir/b/c/d')
  
  ario = rio('adir')
  ario /= 'afile.rb'        #=> rio('adir/afile.rb')
  
			     # File lib/rio/if/path.rb, line 352
352:       def /(arg) 
353:         target / arg 
354:       end
		      
abs(*args) click to toggle source

Returns a new rio with a path equal to the absolute path of this rio

 rio('/tmp').chdir
 rio('afile').abs # => rio('/tmp/afile')
			     # File lib/rio/if/path.rb, line 111
111:       def abs(*args) target.abs(*args)  end
		      
base() click to toggle source

Returns a new Rio whose path is the base path that is used by #abs to create an absolute Rio from a relative one.

 rio('/tmp').chdir
 rio('afile').base # => rio('/tmp/')

See #abs.

			     # File lib/rio/if/path.rb, line 129
129:       def base() target.base()  end
		      
basename(*args) click to toggle source

Similar to File#basename

Returns a Rio whose path is that returned by File#basename when passed the path of a rio and the value returned by File#extname. This differs from the behaviour of File#basename.

 File.basename('afile.txt')                           #=> 'afile.txt'
 File.basename('afile.txt',File.extname('afile.txt')) #=> 'afile'
 rio('afile.txt').basename                            #=> rio('afile')
 rio('afile.txt').basename('.txt')                    #=> same thing
 rio('afile.txt').ext('.txt').basename                #=> same thing

See also #ext,#ext?,#filename,

			     # File lib/rio/if/path.rb, line 206
206:       def basename(*args) target.basename(*args) end
		      
basename=(arg) click to toggle source

Replace the part of the path returned by #basename. If in rename mode, also renames the referenced filesystem object.

Returns the new value of basename

  ario = rio('dirA/dirB/afile.rb')
  ario.dirname = 'dirC'          # rio('dirC/afile.rb')
  ario.basename = 'bfile'        # rio('dirC/bfile.rb')
  ario.extname = '.txt'          # rio('dirC/bfile.txt')
  ario.filename = 'cfile.rb'     # rio('dirC/cfile.rb')

  rio('adir/afile.txt').rename.filename = 'bfile.rb' # adir/afile.txt => adir/bfile.rb
  rio('adir/afile.txt').rename.basename = 'bfile'    # adir/afile.txt => adir/bfile.txt
  rio('adir/afile.txt').rename.extname  = '.rb'      # adir/afile.txt => adir/afile.rb
  rio('adir/afile.txt').rename.dirname =  'b/c'      # adir/afile.txt => b/c/afile.txt

See #basename, #rename

			     # File lib/rio/if/path.rb, line 258
258:       def basename=(arg) target.basename = arg end
		      
cleanpath(consider_symlink=false) click to toggle source

Calls Pathname#cleanpath

Returns a new Rio whose path is the clean pathname of self with consecutive slashes and useless dots removed. The filesystem is not accessed.

If consider_symlink is true, then a more conservative algorithm is used to avoid breaking symbolic linkages. This may retain more .. entries than absolutely necessary, but without accessing the filesystem, this can’t be avoided. See #realpath.

			     # File lib/rio/if/path.rb, line 459
459:       def cleanpath(consider_symlink=false) target.cleanpath(consider_symlink)  end
		      
dirname(*args) click to toggle source

Calls File#dirname

Returns a new Rio referencing the directory portion of a Rio.

   rio('/tmp/zippy.txt').dirname   #=> rio('/tmp')
			     # File lib/rio/if/path.rb, line 214
214:       def dirname(*args) target.dirname(*args) end
		      
dirname=(arg) click to toggle source

Replace the part of the path returned by #dirname. If in rename mode, also renames the referenced filesystem object.

Returns the new value of dirname

  ario = rio('dirA/dirB/afile.rb')
  ario.dirname = 'dirC'          # rio('dirC/afile.rb')
  ario.basename = 'bfile'        # rio('dirC/bfile.rb')
  ario.extname = '.txt'          # rio('dirC/bfile.txt')
  ario.filename = 'cfile.rb'     # rio('dirC/cfile.rb')

  rio('adir/afile.txt').rename.filename = 'bfile.rb' # adir/afile.txt => adir/bfile.rb
  rio('adir/afile.txt').rename.basename = 'bfile'    # adir/afile.txt => adir/bfile.txt
  rio('adir/afile.txt').rename.extname  = '.rb'      # adir/afile.txt => adir/afile.rb
  rio('adir/afile.txt').rename.dirname =  'b/c'      # adir/afile.txt => b/c/afile.txt

See #dirname, #rename

			     # File lib/rio/if/path.rb, line 279
279:       def dirname=(arg) target.dirname  = arg end
		      
expand_path(*args) click to toggle source

Calls File#expand_path

Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless dir_string is given, in which case it will be used as the starting point. The given pathname may start with a ``~��, which expands to the process owner�s home directory (the environment variable HOME must be set correctly). ``~user�� expands to the named user�s home directory.

Returns a Rio representing the returned path

			     # File lib/rio/if/path.rb, line 104
104:       def expand_path(*args) target.expand_path(*args) end
		      
ext(arg=nil) click to toggle source

Sets the string that the Rio considers an extension. The value will be used by subsequent calls to #basename. If called with no arguments resets its value to the value returned by File#extname. Returns the Rio.

 ario = rio('afile.tar.gz')
 ario.ext?                        #=> '.gz'
 ario.basename                    #=> rio('afile.tar')
 ario.ext('.tar.gz').basename     #=> rio('afile')
 ario.ext?                        #=> '.tar.gz'

 ario = rio('afile.txt')
 ario.ext('.txt').basename        #=> rio('afile')
 ario.ext('.zip').basename        #=> rio('afile.txt')
 ario.ext.basename                #=> rio('afile')
 ario.ext('').basename            #=> rio('afile.txt')

See also #ext?,#noext,#basename,

			     # File lib/rio/if/path.rb, line 150
150:       def ext(arg=nil) target.ext(arg); self end
		      
ext?() click to toggle source

Returns the value of the Rio’s ‘ext’ variable This defaults to the value returned by #extname and may be set by either calling #ext or by passing an argument #basename See also #basename, #ext, #extname, #noext

 ario = rio('afile.txt')
 ario.ext?                        #=> '.txt'
 ario.ext('.txt').basename        #=> rio('afile')
 ario.ext?                        #=> '.txt'
 ario.ext('.zip').basename        #=> rio('afile.txt')
 ario.ext?                        #=> '.zip'
 ario.basename('.tar')            #=> rio('afile.txt')
 ario.ext?                        #=> '.tar'
 ario.ext.basename                #=> rio('afile')
 ario.ext?                        #=> '.txt'
 ario.noext.basename              #=> rio('afile.txt')
 ario.ext?                        #=> ''
			     # File lib/rio/if/path.rb, line 181
181:       def ext?() target.ext?() end
		      
extname(*args) click to toggle source

Calls File#extname

Returns a String containing the path’s extension

   rio('/tmp/zippy.txt').extname   #=> '.txt'
			     # File lib/rio/if/path.rb, line 189
189:       def extname(*args) target.extname(*args) end
		      
extname=(arg) click to toggle source

Replace the part of the path returned by #extname. If in rename mode, also renames the referenced filesystem object.

Returns the extension

  ario = rio('dirA/dirB/afile.rb')
  ario.extname = '.txt'          # rio('dirC/bfile.txt')

  rio('adir/afile.txt').rename.extname  = '.rb'      # adir/afile.txt => adir/afile.rb

See aslo #extname, #rename

			     # File lib/rio/if/path.rb, line 237
237:       def extname=(arg) target.extname = arg end
		      
filename() click to toggle source

Returns a new Rio with all path information stripped away. This is similar to #basename, except that it always includes an extension if one exists

 rio('apath/afile.txt').filename #=> rio('afile.txt')
			     # File lib/rio/if/path.rb, line 222
222:       def filename() target.filename() end
		      
filename=(arg) click to toggle source

Replace the part of the path returned by #filename. If in rename mode, also renames the referenced filesystem object.

Returns the new value of filename

  ario = rio('dirA/dirB/afile.rb')
  ario.dirname = 'dirC'          # rio('dirC/afile.rb')
  ario.basename = 'bfile'        # rio('dirC/bfile.rb')
  ario.extname = '.txt'          # rio('dirC/bfile.txt')
  ario.filename = 'cfile.rb'     # rio('dirC/cfile.rb')

  rio('adir/afile.txt').rename.filename = 'bfile.rb' # adir/afile.txt => adir/bfile.rb
  rio('adir/afile.txt').rename.basename = 'bfile'    # adir/afile.txt => adir/bfile.txt
  rio('adir/afile.txt').rename.extname  = '.rb'      # adir/afile.txt => adir/afile.rb
  rio('adir/afile.txt').rename.dirname =  'b/c'      # adir/afile.txt => b/c/afile.txt

See #filename, #rename

			     # File lib/rio/if/path.rb, line 301
301:       def filename=(arg) target.filename = arg end
		      
fspath() click to toggle source

Returns the path for the Rio on the underlying file system Returns nil if the Rio is not on the filesystem (i.e. stdin: or http: Rios)

			    # File lib/rio/if/path.rb, line 85
85:       def fspath() target.fspath() end
		      
host(*args) click to toggle source

Calls URI#host for Rios which have a URI. Otherwise raises NoMethodError.

 rio('http://ruby-doc.org/').host #=> 'ruby-doc'
			     # File lib/rio/if/path.rb, line 411
411:       def host(*args) target.host(*args) end
		      
join(*args) click to toggle source

Creates new Rio by adding args as additional directory components like File#join.

  ario = rio('adir')
  brio = rio('b')
  crio = ario.join(brio)    #=> rio('adir/b')

  ario = rio('adir')
  ario.join('b','c','d')    #=> rio('ario/b/c/d')

See also #/

			     # File lib/rio/if/path.rb, line 314
314:       def join(*args) target.join(*args) end
		      
join!(*args) click to toggle source

Changes a Rio inplace by adding args as additional directory components like #join,

			     # File lib/rio/if/path.rb, line 371
371:       def join!(*args) target.join!(*args); self end
		      
merge(other) click to toggle source

Calls URI#merge

Merges two Rios. URI#merge does not document exactly what merging two URIs means. This appears to join the paths like other + path. See URI#merge for less information.

			     # File lib/rio/if/path.rb, line 431
431:       def merge(other) target.merge(other)  end
		      
noext() click to toggle source

Identical to #ext(’’)

 ario.basename                  #=> rio('afile')
 ario.noext.basename            #=> rio('afile.txt')

See also #ext

			     # File lib/rio/if/path.rb, line 160
160:       def noext() target.noext(); self end
		      
opaque(*args) click to toggle source

Calls URI#opaque for Rios which have URI representations. The opaque portion of a URI is the portion after the colon and before the question-mark beginning the query.

 rio('http://example.org/do.cgi?n=1').opaque  #=> '//example.org/do.cgi'

For Rios that do not have URL representations, returns the same part of Rio’s internal psuedo-URL

			     # File lib/rio/if/path.rb, line 421
421:       def opaque(*args) target.opaque(*args) end
		      
path(*args) click to toggle source

Returns the path for the Rio, which is defined differently for different types of Rios.

For Rios representing paths on the underlying file system this is an alias #fspath. For Rios with paths that are not on the file system this is an alias for #urlpath.

Otherwise this returns nil.

			    # File lib/rio/if/path.rb, line 64
64:       def path(*args) target.path(*args) end
		      
realpath() click to toggle source

Calls Pathname#realpath

Returns a new Rio whose path is the real (absolute) pathname of self in the actual filesystem. The real pathname doesn’t contain symlinks or useless dots.

			     # File lib/rio/if/path.rb, line 467
467:       def realpath() target.realpath()  end
		      
rel(other=nil) click to toggle source

Returns a new rio with a path equal to the relative path from other

 rio('/tmp/afile').rel('/tmp')   #=> rio('afile')
 rio('zippy/afile').rel('zippy') #=> rio('afile')
			     # File lib/rio/if/path.rb, line 118
118:       def rel(other=nil) target.rel(other)  end
		      
route_from(other) click to toggle source

Calls URI#route_from

Returns a new rio representing the path to this Rio from the perspective of other. URI#route_from requires that absolute URIs be used. #route_from does not.

			     # File lib/rio/if/path.rb, line 439
439:       def route_from(other) target.route_from(other)  end
		      
route_to(other) click to toggle source

Calls URI#route_to

Returns a new rio representing the path to other from the perspective of this Rio. URI#route_to requires that absolute URIs be used. #route_to does not.

			     # File lib/rio/if/path.rb, line 446
446:       def route_to(other) target.route_to(other)  end
		      
scheme(*args) click to toggle source

Returns the scheme for the Rio’s URI-like URI#scheme where the Rio is represented by a standard URI. For Rios that are not represented by standard URIs one of Rio’s non-standard schemes is returned.

 rio('http://ruby-doc.org/').scheme #=> 'http'
			     # File lib/rio/if/path.rb, line 405
405:       def scheme(*args) target.scheme(*args) end
		      
splitpath() click to toggle source

Returns an array of Rios, one for each path element. (Note that this behavior differs from File#split.)

 rio('a/b/c').split   #=> [rio('a'),rio('b'),rio('c')]

The array returned is extended with a to_rio method, which will put the parts back together again.

 ary = rio('a/b/c').split   #=> [rio('a'),rio('b'),rio('c')]
 ary.to_rio           #=> rio('a/b/c')

 ary = rio('a/b/c').split   #=> [rio('a'),rio('b'),rio('c')]
 ary[1] = rio('d')
 ary.to_rio           #=> rio('a/d/c')

See also #join, #/

			     # File lib/rio/if/path.rb, line 334
334:       def splitpath() target.splitpath() end
		      
to_uri() click to toggle source

For resources that have a URL (RFC1738) representation, this returns a URI object referencing it. Otherwise this raises NoMethodError.

 rio('http://rubyforge.org/').to_uri     #=> <URI::HTTP:0x818bd84 URL:http://rubyforge.org/>
 rio('adir/afile').to_uri                #=> <URI::Generic:0x817d288 URL:adir/afile>
			    # File lib/rio/if/path.rb, line 81
81:       def to_uri() target.to_uri end
		      
to_url() click to toggle source

For resources that have a absolute URL (RFC1738) representation, this returns a string containing that representation. For objects that do not this returns a RIORL (a descriptive pseudo-URL).

 rio('/var/www/')                  #=> "file:///var/www/"
 rio('http://rio.rubyforge.org/')  #=> "http://rio.rubyforge.org"
 
			    # File lib/rio/if/path.rb, line 73
73:       def to_url() target.to_url end
		      
urlpath() click to toggle source

Returns the path portion of the URL representation of the rio Returns nil if the Rio URL has no path (i.e. stdin: or http: Rios)

			    # File lib/rio/if/path.rb, line 89
89:       def urlpath() target.urlpath() end
		      

Copyright © 2005,2006,2007,2008,2009,2010 Christopher Kleckner. All rights reserved.