Class: LogStash::Inputs::S3L::SinceDB::File
- Inherits:
-
Object
- Object
- LogStash::Inputs::S3L::SinceDB::File
- Defined in:
- lib/logstash/inputs/s3l.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ File
constructor
A new instance of File.
- #newer?(date) ⇒ Boolean
- #read ⇒ Object
- #write(since = nil) ⇒ Object
Constructor Details
#initialize(file) ⇒ File
Returns a new instance of File.
418 419 420 |
# File 'lib/logstash/inputs/s3l.rb', line 418 def initialize(file) @sincedb_path = file end |
Instance Method Details
#newer?(date) ⇒ Boolean
422 423 424 |
# File 'lib/logstash/inputs/s3l.rb', line 422 def newer?(date) date > read end |
#read ⇒ Object
426 427 428 429 430 431 432 433 434 |
# File 'lib/logstash/inputs/s3l.rb', line 426 def read if ::File.exists?(@sincedb_path) content = ::File.read(@sincedb_path).chomp.strip # If the file was created but we didn't have the time to write to it return content.empty? ? Time.new(0) : Time.parse(content) else return Time.new(0) end end |
#write(since = nil) ⇒ Object
436 437 438 439 |
# File 'lib/logstash/inputs/s3l.rb', line 436 def write(since = nil) since = Time.now() if since.nil? ::File.open(@sincedb_path, 'w') { |file| file.write(since.to_s) } end |