Module: RIO::Ops::Stream::Input

Includes:
Enumerable, Cp::Stream::Input, Grande, Read, Status, Piper::Cp::Input
Included in:
Stream::InOut, Stream::Input
Defined in:
lib/rio/ops/stream/input.rb,
lib/rio/ops/stream/input.rb

Instance Method Summary collapse

Methods included from Piper::Cp::Input

#has_output_dest?, #last_rio, #|

Methods included from Cp::Stream::Input

#>, #>>

Methods included from Cp::Util::InOut

#cpclose, #cpclose0

Methods included from Grande

#[]

Methods included from Match::Common

#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



252
253
254
255
256
# File 'lib/rio/ops/stream/input.rb', line 252

def close_read(&block)
  self.ior.close_read
  each(&block) if block_given?
  self
end

#copy_stream(dst) ⇒ Object



258
259
260
261
262
# File 'lib/rio/ops/stream/input.rb', line 258

def copy_stream(dst)
  #p callstr('copy_stream',dst)
  ior.copy_stream(dst)
  self
end

#each(*args, &block) ⇒ Object



57
58
59
60
61
# File 'lib/rio/ops/stream/input.rb', line 57

def each(*args,&block)
  #p callstr('each',*args)
  each_(*args,&block)
  self
end

#each_0(sel, &block) ⇒ Object



274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/rio/ops/stream/input.rb', line 274

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



65
66
67
68
69
# File 'lib/rio/ops/stream/input.rb', line 65

def each_record(*args,&block)
  #p callstr('each_record',*args)
  each_record_(*args,&block)
  self
end

#each_row(*args, &block) ⇒ Object



71
72
73
74
75
# File 'lib/rio/ops/stream/input.rb', line 71

def each_row(*args,&block) 
  #p callstr('each_row',*args)
  rows(*args,&block)
  self
end

#empty?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/rio/ops/stream/input.rb', line 62

def empty?()
  self.eof?
end

#getObject



96
97
98
99
100
101
102
103
# File 'lib/rio/ops/stream/input.rb', line 96

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



77
78
79
80
81
82
83
84
85
86
# File 'lib/rio/ops/stream/input.rb', line 77

def get_type(itertype,&block)
  old_itertype = cx['stream_itertype']
  _set_itertype(itertype)
  begin
    ans = yield
  ensure
    _set_itertype(old_itertype)
  end
  ans
end

#getlineObject



87
88
89
# File 'lib/rio/ops/stream/input.rb', line 87

def getline()
  get_type('lines') { get() }
end

#getrecObject



93
94
95
# File 'lib/rio/ops/stream/input.rb', line 93

def getrec()
  get_type('records') { get() }
end

#getrowObject



90
91
92
# File 'lib/rio/ops/stream/input.rb', line 90

def getrow()
  get_type('rows') { get() }
end

#recnoObject



264
265
266
267
# File 'lib/rio/ops/stream/input.rb', line 264

def recno()
  return nil unless @recno >= 0
  @recno
end

#rewind(&block) ⇒ Object



245
246
247
248
249
250
# File 'lib/rio/ops/stream/input.rb', line 245

def rewind(&block)
  self.ior.rewind
  @recno = -1
  each(&block) if block_given?
  self
end

#to_hObject



269
270
271
# File 'lib/rio/ops/stream/input.rb', line 269

def to_h
  { self.to_s => self.to_a }
end