Class: RIO::Rio
- Includes:
- Enumerable, IF::CSV, IF::Dir, IF::Ext, IF::File, IF::FileOrDir, IF::Grande, IF::GrandeEntry, IF::GrandeStream, IF::Path, IF::RubyIO, IF::String, IF::Test, IF::YAML, Local
- Defined in:
- lib/rio.rb,
lib/rio.rb,
lib/rio/if.rb,
lib/rio/def.rb,
lib/rio/if/dir.rb,
lib/rio/kernel.rb,
lib/rio/if/file.rb,
lib/rio/if/path.rb,
lib/rio/if/temp.rb,
lib/rio/if/test.rb,
lib/rio/if/basic.rb,
lib/rio/construct.rb,
lib/rio/if/grande.rb,
lib/rio/if/rubyio.rb,
lib/rio/if/string.rb,
lib/rio/if/string.rb,
lib/rio/if/internal.rb,
lib/rio/if/fileordir.rb,
lib/rio/if/grande_entry.rb,
lib/rio/if/grande_stream.rb
Overview
See also: RIO::Doc::SYNOPSIS; RIO::Doc::INTRO; RIO::Doc::HOWTO.
Constant Summary collapse
- USE_IF =
:nodoc:
true
Constants included from Local
Local::ROOT_DIR, Local::SEPARATOR
Class Method Summary collapse
-
.rio(*args, &block) ⇒ Object
See RIO.rio.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Comparison for sorting; compare as strings.
-
#==(other) ⇒ Object
Equality - calls to_s on other and compares its return value with the value returned by Rio#to_s.
-
#===(other) ⇒ Object
Equality (for case statements) same as Rio#==.
-
#=~(other) ⇒ Object
Match - invokes other.=~, passing the value returned by Rio#to_str.
-
#copyclose ⇒ Object
This is an internal function and is not needed in client code.
-
#cpclose(*args, &block) ⇒ Object
This is an internal function and is not needed in client code.
-
#cx ⇒ Object
This is an internal function and is not needed in client code.
-
#cx=(arg) ⇒ Object
This is an internal function and is not needed in client code.
- #dup ⇒ Object
-
#each_record(*args, &block) ⇒ Object
This is an internal function and is not needed in client code.
-
#each_row(*args, &block) ⇒ Object
This is an internal function and is not needed in client code.
-
#getwd(*args) ⇒ Object
This is an internal function and is not needed in client code.
-
#hash ⇒ Object
Rios are hashed based on their String representation.
-
#initialize(*args) ⇒ Rio
constructor
See RIO.rio.
- #initialize_copy(*args) ⇒ Object
-
#inputmode? ⇒ Boolean
This is an internal function and is not needed in client code.
- #inspect ⇒ Object
-
#iostate(sym) ⇒ Object
This is an internal function and is not needed in client code.
-
#length ⇒ Object
Returns the length of the Rio’s String representation.
-
#method_missing(sym, *args, &block) ⇒ Object
:nodoc:.
-
#nostreamenum ⇒ Object
This is an internal function and is not needed in client code.
-
#outputmode? ⇒ Boolean
This is an internal function and is not needed in client code.
-
#reset ⇒ Object
This is an internal function and should not normally be needed in client code.
-
#rl ⇒ Object
This is an internal function and is not needed in client code.
-
#rl=(arg) ⇒ Object
This is an internal function and is not needed in client code.
-
#stream_iter? ⇒ Boolean
This is an internal function and is not needed in client code.
-
#string ⇒ Object
Returns the String associated with a Rio which references a StringIO object.
-
#to_ary ⇒ Object
Returns nil.
-
#to_rl ⇒ Object
This is an internal function and is not needed in client code.
-
#to_s ⇒ Object
(also: #to_str, #to_path)
Returns the string representation of a Rio that is used by Ruby’s libraries.
-
#uri ⇒ Object
This is an internal function and is not needed in client code.
Methods included from IF::GrandeStream
#+@, #a, #a!, #bytes, #chomp, #chomp?, #closeoncopy, #closeoncopy?, #closeoneof, #closeoneof?, #contents, #getline, #getrec, #getrow, #gzip, #gzip?, #line, #lines, #noautoclose, #nocloseoncopy, #nocloseoneof, #putrec, #r, #r!, #record, #records, #row, #rows, #skiplines, #skiprecords, #skiprows, #splitlines, #strip, #strip?, #w, #w!
Methods included from IF::GrandeEntry
#all, #all?, #dirs, #entries, #files, #norecurse, #recurse, #skipdirs, #skipentries, #skipfiles
Methods included from IF::FileOrDir
#open, #pos, #pos=, #read, #readlink, #rename, #rename!, #reopen, #rewind, #seek, #symlink, #tell
Methods included from IF::String
Methods included from IF::RubyIO
#binmode, #close, #close_write, #each_byte, #each_line, #eof?, #fcntl, #fileno, #flush, #fsync, #getc, #gets, #ioctl, #ioh, #ios, #lineno, #lineno=, #mode, #mode?, #nosync, #pid, #print, #print!, #printf, #printf!, #putc, #putc!, #puts, #puts!, #readline, #readlines, #readpartial, #recno, #sync, #sync?, #to_i, #to_io, #tty?, #ungetc, #write, #write!
Methods included from IF::Test
#abs?, #absolute?, #atime, #blockdev?, #chardev?, #closed?, #ctime, #dir?, #directory?, #executable?, #executable_real?, #exist?, #file?, #fnmatch?, #ftype, #grpowned?, #lstat, #mountpoint?, #mtime, #open?, #owned?, #pipe?, #readable?, #readable_real?, #root?, #setgid?, #setuid?, #size, #size?, #socket?, #stat, #sticky?, #symlink?, #writable?, #writable_real?, #zero?
Methods included from IF::Path
#/, #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, #rootpath, #route_from, #route_to, #scheme, #splitpath, #to_uri, #to_url, #urlpath
Methods included from IF::File
#clear, #rm, #touch, #truncate
Methods included from IF::Dir
#chdir, #find, #glob, #mkdir, #mkpath, #rmdir, #rmtree
Methods included from IF::YAML
#document, #documents, #dump, #getobj, #load, #object, #objects, #putobj, #putobj!, #skipdocuments, #skipobjects, #yaml, #yaml?
Methods included from IF::CSV
Methods included from IF::Ext
Methods included from IF::Grande
#<, #<<, #>, #>>, #[], #append_from, #append_to, #copy_from, #copy_to, #delete, #delete!, #each, #empty?, #get, #skip, #split, #to_a, #unlink, #|
Methods inherited from Base
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
:nodoc:
148 149 150 151 152 153 154 155 |
# File 'lib/rio.rb', line 148 def method_missing(sym,*args,&block) #:nodoc: # p callstr('method_missing',sym,*args) result = target.__send__(sym,*args,&block) return result unless result.kind_of? State::Base and result.equal? target self end |
Class Method Details
.rio(*args, &block) ⇒ Object
See RIO.rio
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rio.rb', line 76 def self.rio(*args,&block) # :yields: self ario = new(*args) if block_given? old_closeoncopy = ario.closeoncopy? begin yield ario.nocloseoncopy ensure ario.reset.closeoncopy(old_closeoncopy) end end ario end |
Instance Method Details
#<=>(other) ⇒ Object
Comparison for sorting; compare as strings.
137 |
# File 'lib/rio.rb', line 137 def <=>(other) self.to_str <=> other.to_str end |
#==(other) ⇒ Object
Equality - calls to_s on other and compares its return value with the value returned by Rio#to_s
125 126 127 128 129 130 131 |
# File 'lib/rio.rb', line 125 def ==(other) begin target == other.to_str rescue NoMethodError target == other.to_s end end |
#===(other) ⇒ Object
Equality (for case statements) same as Rio#==
134 |
# File 'lib/rio.rb', line 134 def ===(other) self == other end |
#=~(other) ⇒ Object
Match - invokes other.=~, passing the value returned by Rio#to_str
146 |
# File 'lib/rio.rb', line 146 def =~(other) other =~ self.to_str end |
#copyclose ⇒ Object
This is an internal function and is not needed in client code.
72 73 74 |
# File 'lib/rio/if/internal.rb', line 72 def copyclose() # :nodoc: target.copyclose end |
#cpclose(*args, &block) ⇒ Object
This is an internal function and is not needed in client code.
82 83 84 |
# File 'lib/rio/if/internal.rb', line 82 def cpclose(*args,&block) # :nodoc: target.cpclose(*args,&block) end |
#cx ⇒ Object
This is an internal function and is not needed in client code. It returns the internal ‘Rio Context’ object.
62 63 64 |
# File 'lib/rio/if/internal.rb', line 62 def cx() # :nodoc: target.cx() end |
#cx=(arg) ⇒ Object
This is an internal function and is not needed in client code.
67 68 69 |
# File 'lib/rio/if/internal.rb', line 67 def cx=(arg) # :nodoc: target.cx = arg end |
#dup ⇒ Object
107 108 109 110 |
# File 'lib/rio.rb', line 107 def dup #p callstr('dup',self) self.class.new(self.rl) end |
#each_record(*args, &block) ⇒ Object
This is an internal function and is not needed in client code.
87 88 89 |
# File 'lib/rio/if/internal.rb', line 87 def each_record(*args,&block) # :nodoc: target.each_record(*args,&block) end |
#each_row(*args, &block) ⇒ Object
This is an internal function and is not needed in client code.
92 93 94 |
# File 'lib/rio/if/internal.rb', line 92 def each_row(*args,&block) # :nodoc: target.each_row(*args,&block) end |
#getwd(*args) ⇒ Object
This is an internal function and is not needed in client code.
112 113 114 |
# File 'lib/rio/if/internal.rb', line 112 def getwd(*args) # :nodoc: target.getwd(*args) end |
#hash ⇒ Object
Rios are hashed based on their String representation
140 |
# File 'lib/rio.rb', line 140 def hash() self.to_str.hash end |
#initialize_copy(*args) ⇒ Object
70 71 72 73 |
# File 'lib/rio.rb', line 70 def initialize_copy(*args) super @state = Factory.instance.clone_state(@state) end |
#inputmode? ⇒ Boolean
This is an internal function and is not needed in client code.
102 103 104 |
# File 'lib/rio/if/internal.rb', line 102 def inputmode?() # :nodoc: target.inputmode? end |
#inspect ⇒ Object
157 158 159 160 161 |
# File 'lib/rio.rb', line 157 def inspect() cl = self.class.to_s[5..-1] st = state.target.class.to_s[5..-1] sprintf('#<%s:0x%x:"%s" (%s)>',cl,self.object_id,self.to_url,st) end |
#iostate(sym) ⇒ Object
This is an internal function and is not needed in client code.
107 108 109 |
# File 'lib/rio/if/internal.rb', line 107 def iostate(sym) # :nodoc: target.iostate(sym) end |
#length ⇒ Object
Returns the length of the Rio’s String representation
To get the size of the underlying file system object use RIO::IF::Test#size
121 |
# File 'lib/rio.rb', line 121 def length() target.length end |
#nostreamenum ⇒ Object
This is an internal function and is not needed in client code.
77 78 79 |
# File 'lib/rio/if/internal.rb', line 77 def () # :nodoc: target. end |
#outputmode? ⇒ Boolean
This is an internal function and is not needed in client code.
97 98 99 |
# File 'lib/rio/if/internal.rb', line 97 def outputmode?() # :nodoc: target.outputmode? end |
#reset ⇒ Object
This is an internal function and should not normally be needed in client code. It closes a Rio and returns it to its ‘reset’ state.
32 33 34 |
# File 'lib/rio/if/internal.rb', line 32 def reset() # :nodoc: target.reset() end |
#rl ⇒ Object
This is an internal function and is not needed in client code. It returns the internal ‘Rio Resource Locator’ object.
38 39 40 |
# File 'lib/rio/if/internal.rb', line 38 def rl() # :nodoc: target.rl() end |
#rl=(arg) ⇒ Object
This is an internal function and is not needed in client code. It assigns the internal ‘Rio Resource Locator’ object.
44 45 46 |
# File 'lib/rio/if/internal.rb', line 44 def rl=(arg) # :nodoc: target.rl = arg end |
#stream_iter? ⇒ Boolean
This is an internal function and is not needed in client code.
117 118 119 |
# File 'lib/rio/if/internal.rb', line 117 def stream_iter?() # :nodoc: target.stream_iter? end |
#string ⇒ Object
Returns the String associated with a Rio which references a StringIO object. For any other type of Rio, is undefined.
28 |
# File 'lib/rio/if/string.rb', line 28 def string() target.string end |
#to_ary ⇒ Object
Returns nil. Needed for 1.9.2+ problem with to_ary and method_missing.
113 114 115 |
# File 'lib/rio.rb', line 113 def to_ary nil end |
#to_rl ⇒ Object
This is an internal function and is not needed in client code. It returns the internal ‘Rio Resource Locator’ object.
56 57 58 |
# File 'lib/rio/if/internal.rb', line 56 def to_rl() # :nodoc: target.to_rl() end |
#to_s ⇒ Object Also known as: to_str, to_path
Returns the string representation of a Rio that is used by Ruby’s libraries. For Rios that exist on the file system this is Rio#fspath. For FTP and HTTP Rios, this is the URL.
rio('/a/b/c').to_s ==> "/a/b/c"
rio('b/c').to_s ==> "b/c"
rio('C:/b/c').to_s ==> "C:/b/c"
rio('//ahost/a/b').to_s ==> "//ahost/a/b"
rio('file://ahost/a/b').to_s ==> "//ahost/a/b"
rio('file:///a/b').to_s ==> "/a/b"
rio('file://localhost/a/b').to_s ==> "/a/b"
rio('http://ahost/index.html').to_s ==> "http://ahost/index.html"
102 |
# File 'lib/rio.rb', line 102 def to_s() target.to_s end |
#uri ⇒ Object
This is an internal function and is not needed in client code. It returns the internal URI object.
50 51 52 |
# File 'lib/rio/if/internal.rb', line 50 def uri() # :nodoc: target.uri() end |