Class: FileHandler
- Inherits:
-
Object
- Object
- FileHandler
- Defined in:
- lib/logstash/inputs/value_tracking.rb
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(path) ⇒ FileHandler
constructor
A new instance of FileHandler.
- #read ⇒ Object
- #write(value) ⇒ Object
Constructor Details
#initialize(path) ⇒ FileHandler
Returns a new instance of FileHandler.
51 52 53 54 |
# File 'lib/logstash/inputs/value_tracking.rb', line 51 def initialize(path) @path = path @exists = ::File.exist?(@path) end |
Instance Method Details
#clean ⇒ Object
56 57 58 59 60 |
# File 'lib/logstash/inputs/value_tracking.rb', line 56 def clean return unless @exists ::File.delete(@path) @exists = false end |
#read ⇒ Object
62 63 64 65 |
# File 'lib/logstash/inputs/value_tracking.rb', line 62 def read return unless @exists YAML.load(::File.read(@path)) end |
#write(value) ⇒ Object
67 68 69 70 |
# File 'lib/logstash/inputs/value_tracking.rb', line 67 def write(value) ::File.write(@path, YAML.dump(value)) @exists = true end |