Class: Rack::Logs::Viewer::JoinedFiles

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rack/logs/viewer.rb

Instance Method Summary collapse

Constructor Details

#initialize(filenames, lines) ⇒ JoinedFiles

Returns a new instance of JoinedFiles.



30
31
32
33
# File 'lib/rack/logs/viewer.rb', line 30

def initialize filenames, lines
  @filenames = filenames
  @lines = lines
end

Instance Method Details

#each(&block) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/rack/logs/viewer.rb', line 39

def each &block
  @filenames.each do |filename|
    block.call "## #{filename}\n\n"
    ::File.open(filename) do |file|
      tail(file, @lines).each do |line|
        block.call line
      end
    end
  end
end

#empty?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rack/logs/viewer.rb', line 35

def empty?
  @filenames.empty?
end