Class: RIO::Rio

Inherits:
Base show all
Includes:
Enumerable, IF::CSV, IF::Ext, IF::File, IF::FileOrDir, IF::Grande, IF::GrandeEntry, IF::GrandeStream, IF::String, IF::YAML, Local
Defined in:
lib/rio.rb,
lib/rio.rb,
lib/rio/if.rb,
lib/rio/if.rb,
lib/rio/def.rb,
lib/rio/kernel.rb,
lib/rio/if/file.rb,
lib/rio/if/temp.rb,
lib/rio/if/basic.rb,
lib/rio/construct.rb,
lib/rio/if/grande.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

Constants inherited from Base

Base::KEEPSYM

Class Method Summary collapse

Instance Method Summary collapse

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

#+, #gsub, #sub

Methods included from IF::File

#clear, #rm, #touch, #truncate

Methods included from IF::YAML

#documents, #dump, #getobj, #load, #objects, #putobj, #putobj!, #skipdocuments, #skipobjects, #yaml, #yaml?

Methods included from IF::CSV

#columns, #csv, #skipcolumns

Methods included from IF::Ext

#zipfile

Methods included from IF::Grande

#<, #<<, #>, #>>, #[], #append_from, #append_to, #copy_from, #copy_to, #delete, #delete!, #each, #empty?, #get, #skip, #split, #to_a, #|

Constructor Details

#initialize(*args) ⇒ Rio

See RIO.rio



64
65
66
# File 'lib/rio.rb', line 64

def initialize(*args)
  @state = Factory.instance.create_state(*args)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object

:nodoc:



109
110
111
112
113
114
115
116
# File 'lib/rio.rb', line 109

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



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rio.rb', line 75

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

Equality - calls to_s on other and compares its return value with the value returned by Rio#to_s



49
# File 'lib/rio/if/basic.rb', line 49

def ==(other) target == other end

#===(other) ⇒ Object

Equality (for case statements) same as Rio#==



52
# File 'lib/rio/if/basic.rb', line 52

def ===(other) target === other end

#=~(other) ⇒ Object

Match - invokes other.=~, passing the value returned by Rio#to_str



61
# File 'lib/rio/if/basic.rb', line 61

def =~(other) target =~ other end

#copycloseObject

This is an internal function and is not needed in client code.



73
74
75
# File 'lib/rio/if/internal.rb', line 73

def copyclose() # :nodoc:
  target.copyclose 
end

#cpclose(*args, &block) ⇒ Object

This is an internal function and is not needed in client code.



83
84
85
# File 'lib/rio/if/internal.rb', line 83

def cpclose(*args,&block) # :nodoc:
  target.cpclose(*args,&block) 
end

#cxObject

This is an internal function and is not needed in client code. It returns the internal ‘Rio Context’ object.



63
64
65
# File 'lib/rio/if/internal.rb', line 63

def cx() # :nodoc:
  target.cx() 
end

#cx=(arg) ⇒ Object

This is an internal function and is not needed in client code.



68
69
70
# File 'lib/rio/if/internal.rb', line 68

def cx=(arg) # :nodoc:
  target.cx = arg 
end

#dupObject



104
105
106
107
# File 'lib/rio.rb', line 104

def dup
  #p callstr('dup',self)
  self.class.new(self.to_rl)
end

#each_record(*args, &block) ⇒ Object

This is an internal function and is not needed in client code.



88
89
90
# File 'lib/rio/if/internal.rb', line 88

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.



93
94
95
# File 'lib/rio/if/internal.rb', line 93

def each_row(*args,&block) # :nodoc:
  target.each_row(*args,&block) 
end

#eql?(other) ⇒ Boolean

Returns true if their String representations are eql?

Returns:

  • (Boolean)


58
# File 'lib/rio/if/basic.rb', line 58

def eql?(other) target.eql?(other) end

#getwd(*args) ⇒ Object

This is an internal function and is not needed in client code.



113
114
115
# File 'lib/rio/if/internal.rb', line 113

def getwd(*args) # :nodoc:
  target.getwd(*args) 
end

#hashObject

Rios are hashed based on their String representation



55
# File 'lib/rio/if/basic.rb', line 55

def hash() target.hash end

#initialize_copy(*args) ⇒ Object



68
69
70
71
72
# File 'lib/rio.rb', line 68

def initialize_copy(*args)
  #p callstr("initialize_copy",args[0].inspect)
  super
  @state = Factory.instance.clone_state(@state)
end

#inputmode?Boolean

This is an internal function and is not needed in client code.

Returns:

  • (Boolean)


103
104
105
# File 'lib/rio/if/internal.rb', line 103

def inputmode?() # :nodoc:
  target.inputmode? 
end

#inspectObject



118
119
120
121
122
# File 'lib/rio.rb', line 118

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.



108
109
110
# File 'lib/rio/if/internal.rb', line 108

def iostate(sym) # :nodoc:
  target.iostate(sym) 
end

#lengthObject

Returns the length of the Rio’s String representation

To get the size of the underlying file system object use RIO::IF::Test#size



45
# File 'lib/rio/if/basic.rb', line 45

def length() target.length end

#nostreamenumObject

This is an internal function and is not needed in client code.



78
79
80
# File 'lib/rio/if/internal.rb', line 78

def nostreamenum() # :nodoc:
  target.nostreamenum 
end

#outputmode?Boolean

This is an internal function and is not needed in client code.

Returns:

  • (Boolean)


98
99
100
# File 'lib/rio/if/internal.rb', line 98

def outputmode?() # :nodoc:
  target.outputmode? 
end

#resetObject

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.



45
46
47
# File 'lib/rio/if/internal.rb', line 45

def reset() # :nodoc:
  target.reset() 
end

#rlObject

This is an internal function and is not needed in client code. It returns the internal ‘Rio Resource Locator’ object.



51
52
53
# File 'lib/rio/if/internal.rb', line 51

def rl() # :nodoc:
  target.rl() 
end

#stream_iter?Boolean

This is an internal function and is not needed in client code.

Returns:

  • (Boolean)


118
119
120
# File 'lib/rio/if/internal.rb', line 118

def stream_iter?() # :nodoc:
  target.stream_iter? 
end

#stringObject

Returns the String associated with a Rio which references a StringIO object. For any other type of Rio, is undefined.



41
# File 'lib/rio/if/string.rb', line 41

def string() target.string end

#to_rlObject

This is an internal function and is not needed in client code. It returns the internal ‘Rio Resource Locator’ object.



57
58
59
# File 'lib/rio/if/internal.rb', line 57

def to_rl() # :nodoc:
  target.to_rl() 
end

#to_sObject Also known as: to_str

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"


101
# File 'lib/rio.rb', line 101

def to_s() target.to_s end