Sha256: f6a80d69fb14959c276863700d8f099febcd0b87653a42d05b2c7633312370ba

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

module Adrian
  class FileItem < QueueItem

    def path
      value
    end

    def name
      File.basename(path)
    end

    def ==(other)
      other.respond_to?(:name) &&
        name == other.name
    end

    def move(destination)
      destination_path = File.join(destination, File.basename(path))
      File.rename(path, destination_path)
      @value = destination_path
    end

    def updated_at
      File.mtime(path).utc
    rescue Errno::ENOENT
      nil
    end

    def touch(updated_at = Time.new)
      File.utime(updated_at, updated_at, path)
    end

    def exist?
      File.exist?(path)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adrian-1.1.0 lib/adrian/file_item.rb
adrian-1.0.1 lib/adrian/file_item.rb