Method: EaseEngine::Watcher#add

Defined in:
lib/ease_engine/watcher.rb

#add(io, callbacks) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ease_engine/watcher.rb', line 55

def add( io, callbacks )
  id = io.to_i
  if @watches.key?( id )
    info = @watches[ id ]
    @watches.delete( id )
    info.detach
  end
  
  flags = ""
  flags = "r" if callbacks.key?( :on_read )
  flags = "#{flags}w" if callbacks.key?( :on_write )
  
  @watches[ id ] = Info.new( io, flags, callbacks )
  @watches[ id ].attach @loop
end