Class: LogStash::Inputs::Multirds::SinceDB::File
- Inherits:
-
Object
- Object
- LogStash::Inputs::Multirds::SinceDB::File
- Defined in:
- lib/logstash/inputs/multirds.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ File
constructor
A new instance of File.
- #read ⇒ Object
- #write(time) ⇒ Object
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
#read ⇒ Object
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 |