Class: Stenohttp2::Common::Watcher
- Inherits:
 - 
      Object
      
        
- Object
 - Stenohttp2::Common::Watcher
 
 
- Defined in:
 - lib/stenohttp2/common/watcher.rb
 
Instance Method Summary collapse
- 
  
    
      #initialize(dir)  ⇒ Watcher 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Watcher.
 - #start ⇒ Object
 
Constructor Details
#initialize(dir) ⇒ Watcher
Returns a new instance of Watcher.
      8 9 10  | 
    
      # File 'lib/stenohttp2/common/watcher.rb', line 8 def initialize(dir) @path = File.(dir) end  | 
  
Instance Method Details
#start ⇒ Object
      12 13 14 15 16 17 18 19 20  | 
    
      # File 'lib/stenohttp2/common/watcher.rb', line 12 def start puts "Listening on #{path} for *.message" listener = Listen.to(path) do |modified, added, _| new_file = added&.first || modified&.first (File.read(new_file)) if new_file&.end_with?('message') end listener.start sleep end  |