Class: TailFromSentinel::Base
- Inherits:
-
Object
- Object
- TailFromSentinel::Base
- 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
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(file, &sentinel) ⇒ Base
constructor
Parameters: file: File IO object &sentinel: Block, taking one parameter.
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/tail_from_sentinel.rb', line 8 def data @data end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
8 9 10 |
# File 'lib/tail_from_sentinel.rb', line 8 def file @file end |