Class: Browserlog::LogReader

Inherits:
Object
  • Object
show all
Defined in:
lib/browserlog/log_reader.rb

Instance Method Summary collapse

Instance Method Details

#read(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/browserlog/log_reader.rb', line 3

def read(options = {})
  offset = options[:offset] || -1
  limit = options[:limit] || 25
  amount = [limit, remaining_lines(offset)].min

  if offset == -1
    line_index = num_lines
    [readlines(amount), line_index]
  else
    line_index = offset + amount
    [readlines(amount), line_index]
  end
end