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.



197
198
199
# File 'lib/logstash/inputs/multirds.rb', line 197

def initialize(file)
  @db = file
end

Instance Method Details

#readObject



201
202
203
204
205
206
207
208
# File 'lib/logstash/inputs/multirds.rb', line 201

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



210
211
212
# File 'lib/logstash/inputs/multirds.rb', line 210

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