Module: RIO::Filter::CloseOnEOF

Defined in:
lib/rio/filter/closeoneof.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#autoclosedObject

Returns the value of attribute autoclosed.



30
31
32
# File 'lib/rio/filter/closeoneof.rb', line 30

def autoclosed
  @autoclosed
end

#oncloseprocObject

Returns the value of attribute oncloseproc.



29
30
31
# File 'lib/rio/filter/closeoneof.rb', line 29

def oncloseproc
  @oncloseproc
end

Class Method Details

.extend_object(ioh) ⇒ Object



31
32
33
34
35
# File 'lib/rio/filter/closeoneof.rb', line 31

def self.extend_object(ioh)
  super
  ioh.autoclosed = false
  ioh.oncloseproc = nil
end

Instance Method Details

#autoclosed?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/rio/filter/closeoneof.rb', line 36

def autoclosed?
  @autoclosed
end

#close_on_eof(&block) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/rio/filter/closeoneof.rb', line 39

def close_on_eof(&block)
  #p callstr('close_on_eof',rtn)
  rtn = yield
  if handle.eof?
    close_on_eof_(rtn)
  end
  rtn
end

#close_on_eof1(&block) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/rio/filter/closeoneof.rb', line 47

def close_on_eof1(&block)
  #p callstr('close_on_eof',rtn)
  if handle.eof?
    close_on_eof_(nil)
    yield
  else
    yield
  end
end

#close_on_eof_(rtn) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/rio/filter/closeoneof.rb', line 56

def close_on_eof_(rtn)
  #p callstr('close_on_eof_',rtn)
  unless @autoclosed or closed?
    #handle.close()
    @oncloseproc.call() unless @oncloseproc.nil?
    @autoclosed = true
  end
  rtn
end

#contentsObject



79
# File 'lib/rio/filter/closeoneof.rb', line 79

def contents()                  close_on_eof{super} end

#copy_stream(dst) ⇒ Object



78
# File 'lib/rio/filter/closeoneof.rb', line 78

def copy_stream(dst)            close_on_eof{super} end

#each_byte(*args, &block) ⇒ Object



67
# File 'lib/rio/filter/closeoneof.rb', line 67

def each_byte(*args,&block)     close_on_eof{super} end

#each_bytes(nb, *args, &block) ⇒ Object



68
# File 'lib/rio/filter/closeoneof.rb', line 68

def each_bytes(nb,*args,&block) close_on_eof{super} end

#each_line(*args, &block) ⇒ Object



66
# File 'lib/rio/filter/closeoneof.rb', line 66

def each_line(*args,&block)     close_on_eof{super} end

#gets(*args) ⇒ Object



73
# File 'lib/rio/filter/closeoneof.rb', line 73

def gets(*args)                 close_on_eof{super} end

#read(*args) ⇒ Object



76
# File 'lib/rio/filter/closeoneof.rb', line 76

def read(*args)                 close_on_eof{super} end

#readchar(*args) ⇒ Object



72
# File 'lib/rio/filter/closeoneof.rb', line 72

def readchar(*args)             close_on_eof{super} end

#readline(*args) ⇒ Object



70
# File 'lib/rio/filter/closeoneof.rb', line 70

def readline(*args)             close_on_eof{super} end

#readlines(*args) ⇒ Object



74
# File 'lib/rio/filter/closeoneof.rb', line 74

def readlines(*args)            close_on_eof{super} end