Class: RIO::IOWrap::Stream

Inherits:
Base show all
Defined in:
lib/rio/iowrap.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#ios

Instance Method Summary collapse

Methods inherited from Base

#callstr, #handle, #initialize_copy, #open?

Constructor Details

#initialize(ios) ⇒ Stream

Returns a new instance of Stream.



58
59
60
61
62
# File 'lib/rio/iowrap.rb', line 58

def initialize(ios)
  @eof = false
  @closed = false
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

def puts(*args)

handle.puts(*args)

end



121
122
123
124
# File 'lib/rio/iowrap.rb', line 121

def method_missing(sym,*args,&block)
  #p callstr('method_missing',sym,*args)
  handle.__send__(sym,*args,&block)
end

Instance Attribute Details

#eofObject (readonly)

Returns the value of attribute eof.



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

def eof
  @eof
end

Instance Method Details

#closeObject



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

def close()
  @closed = true
  handle.close 
end

#closed?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/rio/iowrap.rb', line 67

def closed?() 
  @closed
end

#each(*args, &block) ⇒ Object Also known as: each_line



72
73
74
75
76
# File 'lib/rio/iowrap.rb', line 72

def each(*args,&block)
  rtn = handle.each(*args,&block)
  @eof = true
  rtn
end

#eof?Boolean

Returns:

  • (Boolean)


70
# File 'lib/rio/iowrap.rb', line 70

def eof?() @eof end

#getc(*args) ⇒ Object



82
83
84
85
# File 'lib/rio/iowrap.rb', line 82

def getc(*args)
  @eof = true unless ans = handle.getc(*args)
  ans
end

#gets(*args) ⇒ Object



78
79
80
81
# File 'lib/rio/iowrap.rb', line 78

def gets(*args)
  @eof = true unless ans = handle.gets(*args)
  ans
end

#read(*args) ⇒ Object



99
100
101
102
# File 'lib/rio/iowrap.rb', line 99

def read(*args)
  @eof = true unless ans = handle.read(*args)
  ans
end

#readline(*args) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/rio/iowrap.rb', line 91

def readline(*args)
  begin
    return handle.readline
  rescue EOFError
    @eof = true
    raise
  end
end

#readlines(*args) ⇒ Object



86
87
88
89
90
# File 'lib/rio/iowrap.rb', line 86

def readlines(*args)
  rtn = handle.readlines(*args)
  @eof = true
  rtn
end

#sysread(*args) ⇒ Object



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

def sysread(*args)
  @eof = true unless ans = handle.sysread(*args)
  ans
end