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.
79 80 81 |
# File 'lib/logstash/inputs/multirds.rb', line 79 def initialize(file) @db = file end |
Instance Method Details
#read ⇒ Object
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 |