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.



47
48
49
50
51
# File 'lib/rio/iowrap.rb', line 47

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



97
98
99
100
# File 'lib/rio/iowrap.rb', line 97

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.



46
47
48
# File 'lib/rio/iowrap.rb', line 46

def eof
  @eof
end

Instance Method Details

#closeObject



52
53
54
55
# File 'lib/rio/iowrap.rb', line 52

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

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?() 
  @closed
end

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



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

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

#eof?Boolean

Returns:

  • (Boolean)


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

def eof?() @eof end

#getc(*args) ⇒ Object



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

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

#gets(*args) ⇒ Object



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

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

#read(*args) ⇒ Object



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

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

#readline(*args) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/rio/iowrap.rb', line 80

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

#readlines(*args) ⇒ Object



75
76
77
78
79
# File 'lib/rio/iowrap.rb', line 75

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

#sysread(*args) ⇒ Object



92
93
94
95
# File 'lib/rio/iowrap.rb', line 92

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