Module: RIO::Ops::Stream::Input
Instance Method Summary
collapse
#|
#>, #>>
#cpclose, #cpclose0
Methods included from Grande
#[]
#ss_type?
Methods included from Read
#contents, #each_byte, #each_bytes, #each_line, #getc, #gets, #lineno, #lineno=, #read, #readchar, #readline, #readlines, #readpartial, #ungetc
Methods included from Status
#closed?, #eof?, #open?, #stat
Instance Method Details
#close_read(&block) ⇒ Object
231
232
233
234
235
|
# File 'lib/rio/ops/stream/input.rb', line 231
def close_read(&block)
self.ior.close_read
each(&block) if block_given?
self
end
|
#copy_stream(dst) ⇒ Object
237
238
239
240
241
|
# File 'lib/rio/ops/stream/input.rb', line 237
def copy_stream(dst)
ior.copy_stream(dst)
self
end
|
#each(*args, &block) ⇒ Object
69
70
71
72
73
|
# File 'lib/rio/ops/stream/input.rb', line 69
def each(*args,&block)
each_(*args,&block)
self
end
|
#each_0(sel, &block) ⇒ Object
253
254
255
256
257
258
259
260
261
262
263
264
|
# File 'lib/rio/ops/stream/input.rb', line 253
def each_0(sel,&block)
if sel.match_all?
each_rec_(&block)
else
each_rec_ { |rec|
next unless mtch = sel.match?(rec,@recno)
val = (mtch.kind_of?(::MatchData) && mtch.size > 1 ? mtch.to_a[1...mtch.length] : rec)
yield val
}
end
self
end
|
#each_record(*args, &block) ⇒ Object
77
78
79
80
81
|
# File 'lib/rio/ops/stream/input.rb', line 77
def each_record(*args,&block)
each_record_(*args,&block)
self
end
|
#each_row(*args, &block) ⇒ Object
83
84
85
86
87
|
# File 'lib/rio/ops/stream/input.rb', line 83
def each_row(*args,&block)
rows(*args).each_row_(*args,&block)
self
end
|
#empty? ⇒ Boolean
74
75
76
|
# File 'lib/rio/ops/stream/input.rb', line 74
def empty?()
self.eof?
end
|
89
90
91
92
93
94
95
96
97
|
# File 'lib/rio/ops/stream/input.rb', line 89
def get()
until self.eof?
raw_rec = self._get_rec
return to_rec_(raw_rec) if @get_selrej.match?(raw_rec,@recno)
end
self.close if closeoneof?
nil
end
|
#get_type(itertype, &block) ⇒ Object
(closeoneof? ? self.on_eof_close{ nil } : nil)
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/rio/ops/stream/input.rb', line 98
def get_type(itertype,&block)
old_itertype = cx['stream_itertype']
_set_itertype(itertype)
begin
ans = yield
ensure
_set_itertype(old_itertype)
end
ans
end
|
108
109
110
|
# File 'lib/rio/ops/stream/input.rb', line 108
def getline()
get_type('lines') { get() }
end
|
114
115
116
|
# File 'lib/rio/ops/stream/input.rb', line 114
def getrec()
get_type('records') { get() }
end
|
111
112
113
|
# File 'lib/rio/ops/stream/input.rb', line 111
def getrow()
get_type('rows') { get() }
end
|
243
244
245
246
|
# File 'lib/rio/ops/stream/input.rb', line 243
def recno()
return nil unless @recno >= 0
@recno
end
|
#rewind(&block) ⇒ Object
224
225
226
227
228
229
|
# File 'lib/rio/ops/stream/input.rb', line 224
def rewind(&block)
self.ior.rewind
@recno = -1
each(&block) if block_given?
self
end
|
248
249
250
|
# File 'lib/rio/ops/stream/input.rb', line 248
def to_h
{ self.to_s => self.to_a }
end
|