Class: TailFromSentinel::Base

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

Overview

Parses a file, looking for a sentinel line that satisfies a block, and returns all lines from there until the end of the file (including the sentinel itself)

This can be handy when you are looking for information in a log file only after a certain condition (eg. a date) has been seen.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, &sentinel) ⇒ Base

Parameters:

file: File IO object
&sentinel: Block, taking one parameter. Should return true when the sentinel is found.


13
14
15
16
17
18
# File 'lib/tail_from_sentinel.rb', line 13

def initialize(file, &sentinel)
  @file=file
  @sentinel=sentinel
  load_data
  self
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/tail_from_sentinel.rb', line 8

def data
  @data
end

#fileObject (readonly)

Returns the value of attribute file.



8
9
10
# File 'lib/tail_from_sentinel.rb', line 8

def file
  @file
end