Class: Sinotify::Watch

Inherits:
Object
  • Object
show all
Defined in:
lib/sinotify/watch.rb

Overview

Just a little struct to describe a single inotifier watch Note that the is_dir needs to be saved because we won’t be able to deduce that later if it was a deleted object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Watch

Returns a new instance of Watch.



9
10
11
12
13
# File 'lib/sinotify/watch.rb', line 9

def initialize(args={})
  args.each{|k,v| self.send("#{k}=",v)}
  @timestamp ||= Time.now
  @is_dir = File.directory?(path)
end

Instance Attribute Details

#is_dirObject

Returns the value of attribute is_dir.



8
9
10
# File 'lib/sinotify/watch.rb', line 8

def is_dir
  @is_dir
end

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/sinotify/watch.rb', line 8

def path
  @path
end

#watch_descriptorObject

Returns the value of attribute watch_descriptor.



8
9
10
# File 'lib/sinotify/watch.rb', line 8

def watch_descriptor
  @watch_descriptor
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/sinotify/watch.rb', line 14

def directory?
  self.is_dir.eql?(true)
end

#to_sObject



17
18
19
# File 'lib/sinotify/watch.rb', line 17

def to_s
  "Sinotify::Watch[:is_dir => #{is_dir}, :path => #{path}, :watch_descriptor => #{watch_descriptor}]"
end