Class: DirectoryWatcher::FileStat

### Home Classes Methods

### In Files

- lib/directory_watcher/file_stat.rb

### Parent

Object

### Methods

- ::for_removed_path
- ::new
- #==
- #eql?
- #removed?
- #to_s

### Files

- History.txt
- README.txt

### Class/Module Index

Quicksearch

- DirectoryWatcher
- DirectoryWatcher::Collector
- DirectoryWatcher::Configuration
- DirectoryWatcher::CoolioScanner
- DirectoryWatcher::EmScanner
- DirectoryWatcher::Event
- DirectoryWatcher::EventableScanner
- DirectoryWatcher::FileStat
- DirectoryWatcher::Logable
- DirectoryWatcher::Notifier
- DirectoryWatcher::NullLogger
- DirectoryWatcher::Paths
- DirectoryWatcher::RevScanner
- DirectoryWatcher::Scan
- DirectoryWatcher::ScanAndQueue
- DirectoryWatcher::Scanner
- DirectoryWatcher::Threaded
- DirectoryWatcher::Version
- Object

No matching classes.

# DirectoryWatcher::FileStat

FileStat contains file system information about a single file including:

path - The fully expanded path of the file mtime - The last modified time of the file, as a Time object size - The size of the file, in bytes.

The FileStat object can also say if the file is removed of not.

### Attributes

mtime[RW]

The last modified time of the file

path[R]

The fully expanded path of the file

size[RW]

The size of the file in bytes

### Public Class Methods

for_removed_path( path ) click to toggle source

Create an instance of FileStat that will make sure that the instance method `removed?` returns true when called on it.

    # File lib/directory_watcher/file_stat.rb, line 23
    def self.for_removed_path( path )
      ::DirectoryWatcher::FileStat.new(path, nil, nil)
    end

new( path, mtime, size ) click to toggle source

Create a new instance of FileStat with the given path, mtime and size

    # File lib/directory_watcher/file_stat.rb, line 29
    def initialize( path, mtime, size )
      @path = path
      @mtime = mtime
      @size = size
    end

### Public Instance Methods

==( other ) click to toggle source
Alias for: eql?
eql?( other ) click to toggle source

Compare this FileStat to another object.

This will only return true when all of the following are true:

1) The other object is also a FileStat object 2) The other object's mtime is equal to this mtime 3) The other object's msize is equal to this size

    # File lib/directory_watcher/file_stat.rb, line 54
    def eql?( other )
      return false unless other.instance_of? self.class
      self.mtime == other.mtime and self.size == other.size
    end

Also aliased as: ==
removed?() click to toggle source

Is the file represented by this FileStat to be considered removed?

FileStat doesn't actually go to the file system and check, it assumes if the FileStat was initialized with a nil mtime or a nil size then that data wasn't available, and therefore must indicate that the file is no longer in existence.

    # File lib/directory_watcher/file_stat.rb, line 42
    def removed?
      @mtime.nil? || @size.nil?
    end

to_s() click to toggle source

Create a nice string based representation of this instance.

    # File lib/directory_watcher/file_stat.rb, line 62
    def to_s
      "<#{self.class.name} path: #{path} mtime: #{mtime} size: #{size}>"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.