Class: LogStash::Inputs::Multirds::SinceDB::File

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/inputs/multirds.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ File

Returns a new instance of File.



79
80
81
# File 'lib/logstash/inputs/multirds.rb', line 79

def initialize(file)
  @db = file
end

Instance Method Details

#readObject



83
84
85
86
87
88
89
90
# File 'lib/logstash/inputs/multirds.rb', line 83

def read
  if ::File.exists?(@db)
    content = ::File.read(@db).chomp.strip
    return content.empty? ? Time.new : Time.parse(content)
  else
    return Time.new("1999-01-01")
  end
end

#write(time) ⇒ Object



92
93
94
# File 'lib/logstash/inputs/multirds.rb', line 92

def write(time)
  ::File.open(@db, 'w') { |file| file.write time.to_s }
end