Class: RIO::IOH::Stream
Constant Summary
collapse
- DEFAULT_BLKSIZE =
1024
Instance Attribute Summary collapse
Attributes inherited from Base
#ios
Instance Method Summary
collapse
Methods included from Fwd
fwd, fwd_reader, fwd_readers, fwd_writer, fwd_writers
Methods inherited from Base
#callstr, #ior, #iow, #open?
Constructor Details
#initialize(iosp, *args) ⇒ Stream
Returns a new instance of Stream.
55
56
57
|
# File 'lib/rio/ioh.rb', line 55
def initialize(iosp,*args)
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
129
130
131
132
|
# File 'lib/rio/ioh.rb', line 129
def method_missing(sym,*args,&block)
handle.__send__(sym,*args,&block)
end
|
Instance Attribute Details
54
55
56
|
# File 'lib/rio/ioh.rb', line 54
def hindex
@hindex
end
|
Instance Method Details
#_stat_blksize(st) ⇒ Object
144
145
146
147
148
149
|
# File 'lib/rio/ioh.rb', line 144
def _stat_blksize(st)
s = st.blksize
return nil unless s
return nil if s == 0
s
end
|
#_stream_blksize(*streams) ⇒ Object
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/rio/ioh.rb', line 134
def _stream_blksize(*streams)
sizes = []
streams.each do |s|
next unless s.kind_of?(::IO)
next unless s.respond_to?(:stat)
size = _stat_blksize(s.stat)
sizes << size if size
end
sizes.min || DEFAULT_BLKSIZE
end
|
71
|
# File 'lib/rio/ioh.rb', line 71
def close() handle.close unless self.closed? end
|
#closed? ⇒ Boolean
72
|
# File 'lib/rio/ioh.rb', line 72
def closed?() ios.nil? or ios.closed? end
|
#copy_blksize ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/rio/ioh.rb', line 62
def copy_blksize()
if ios.respond_to? :stat
sz = ios.stat.blksize
sz = nil if sz.nil? || sz == 0
end
sz || 512
end
|
#copy_stream(dst) ⇒ Object
74
75
76
77
78
79
80
81
|
# File 'lib/rio/ioh.rb', line 74
def copy_stream(dst)
blksize = _stream_blksize(handle,dst)
until handle.eof?
dst.print(handle.read(blksize))
end
self
end
|
#each_bytes(nb, &block) ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/rio/ioh.rb', line 85
def each_bytes(nb,&block)
until handle.eof?
break unless s = handle.read(nb)
yield s
end
self
end
|
#eof? ⇒ Boolean
73
|
# File 'lib/rio/ioh.rb', line 73
def eof?() ios.nil? or ios.closed? or ios.eof? end
|
70
|
# File 'lib/rio/ioh.rb', line 70
def handle() ios end
|
#initialize_copy(*args) ⇒ Object
58
59
60
61
|
# File 'lib/rio/ioh.rb', line 58
def initialize_copy(*args)
super
end
|
#puts(*args) ⇒ Object
82
83
84
|
# File 'lib/rio/ioh.rb', line 82
def puts(*args)
handle.puts(*args)
end
|
#set_encoding(*args) ⇒ Object
125
126
127
|
# File 'lib/rio/ioh.rb', line 125
def set_encoding(*args)
handle.set_encoding(*args)
end
|