Sha256: dbf16f47e26155058d75000f56266001f953ae8460bcc125708f898e5f5f586f

Contents?: true

Size: 723 Bytes

Versions: 3

Compression:

Stored size: 723 Bytes

Contents

module Libuv
    class FSEvent < Handle


        EVENTS = {1 => :rename, 2 => :change}.freeze


        def initialize(loop, path)
            @loop = loop

            fs_event_ptr = ::Libuv::Ext.create_handle(:uv_fs_event)
            error = check_result ::Libuv::Ext.fs_event_init(loop.handle, fs_event_ptr, path, callback(:on_fs_event), 0)

            super(fs_event_ptr, error)
        end


        private


        def on_fs_event(handle, filename, events, status)
            e = check_result(status)

            if e
                reject(e)
            else
                defer.notify(filename, EVENTS[events])   # notify of a change
            end
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
libuv-0.11.22 lib/libuv/fs_event.rb
libuv-0.11.4 lib/libuv/fs_event.rb
libuv-0.10.0 lib/libuv/fs_event.rb