Class: DAF::FileUpdateMonitor
- Defined in:
- lib/daf/monitors/file_update_monitor.rb
Overview
Monitor that watches a file’s last update time, and triggers when it changes includes several return outputs that can be used as well
Instance Method Summary collapse
- #block_until_triggered ⇒ Object
-
#contents ⇒ String
The contents of the tile that caused trigger.
-
#initialize(options) ⇒ FileUpdateMonitor
constructor
A new instance of FileUpdateMonitor.
-
#time ⇒ Time
The last modified time of file that caused trigger.
Methods inherited from Monitor
Methods included from Configurable
Constructor Details
#initialize(options) ⇒ FileUpdateMonitor
Returns a new instance of FileUpdateMonitor.
21 22 23 |
# File 'lib/daf/monitors/file_update_monitor.rb', line 21 def initialize() super end |
Instance Method Details
#block_until_triggered ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/daf/monitors/file_update_monitor.rb', line 25 def block_until_triggered initial_modified_time = File.mtime(@path.value) loop do sleep @frequency.value modified_time = File.mtime(@path.value) next unless modified_time > initial_modified_time @time = modified_time @contents = contents_of_file(@path.value) break end end |
#contents ⇒ String
Returns The contents of the tile that caused trigger.
19 |
# File 'lib/daf/monitors/file_update_monitor.rb', line 19 attr_output :contents, String |
#time ⇒ Time
Returns The last modified time of file that caused trigger.
16 |
# File 'lib/daf/monitors/file_update_monitor.rb', line 16 attr_output :time, Time |