Class: LogStash::Inputs::CouchDBChanges::SequenceDB::File
- Inherits:
-
Object
- Object
- LogStash::Inputs::CouchDBChanges::SequenceDB::File
- Defined in:
- lib/logstash/inputs/couchdb_changes.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ File
constructor
A new instance of File.
- #read ⇒ Object
- #write(sequence = nil) ⇒ Object
Constructor Details
#initialize(file) ⇒ File
Returns a new instance of File.
134 135 136 |
# File 'lib/logstash/inputs/couchdb_changes.rb', line 134 def initialize(file) @sequence_path = file end |
Instance Method Details
#read ⇒ Object
138 139 140 |
# File 'lib/logstash/inputs/couchdb_changes.rb', line 138 def read ::File.exists?(@sequence_path) ? ::File.read(@sequence_path).chomp.strip : 0 end |
#write(sequence = nil) ⇒ Object
142 143 144 145 |
# File 'lib/logstash/inputs/couchdb_changes.rb', line 142 def write(sequence = nil) sequence = 0 if sequence.nil? ::File.write(@sequence_path, sequence.to_s) end |