Class: StreamWrapper::GzipMultiFile

Inherits:
Object
  • Object
show all
Defined in:
lib/logbox/stream_wrapper/gzip_multi_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths = [], filters = {}) ⇒ GzipMultiFile

Returns a new instance of GzipMultiFile.



4
5
6
7
8
9
10
11
12
# File 'lib/logbox/stream_wrapper/gzip_multi_file.rb', line 4

def initialize (paths = [], filters = {})
  @paths = paths.is_a?(Array) ? paths.dup : [paths]
  @filters = filters
  if @paths.empty?
    @current_line = 0
    @current_file = $stdin
    @current_path = '<stdin>'
  end
end

Instance Method Details

#closeObject



27
28
29
# File 'lib/logbox/stream_wrapper/gzip_multi_file.rb', line 27

def close
  @current_file.close unless @current_file.nil?
end

#current_positionObject



31
32
33
# File 'lib/logbox/stream_wrapper/gzip_multi_file.rb', line 31

def current_position
  "#{@current_path}:#{@current_line}"
end

#debug=(bool) ⇒ Object



35
36
37
# File 'lib/logbox/stream_wrapper/gzip_multi_file.rb', line 35

def debug= (bool)
  @debug = bool
end

#debug?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/logbox/stream_wrapper/gzip_multi_file.rb', line 39

def debug?
  @debug
end

#eof?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/logbox/stream_wrapper/gzip_multi_file.rb', line 23

def eof?
  ! current_stream
end

#getsObject



14
15
16
17
18
19
20
21
# File 'lib/logbox/stream_wrapper/gzip_multi_file.rb', line 14

def gets
  if file = current_stream
    @current_line += 1
    file.gets
  else
    nil
  end
end