Sha256: d275ac4aad1dd1102dcfd3a1436ac1250f6a9b7e6bec2cce02db9c8f252cf335

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 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
      @updated_at ||= File.mtime(path).utc
    rescue Errno::ENOENT
      nil
    end

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

    def exist?
      File.exist?(path)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adrian-1.1.1 lib/adrian/file_item.rb