Class: LogStash::Inputs::CouchDBChanges::SequenceDB::File

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

Instance Method Summary collapse

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

#readObject



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