Sha256: 7cb4ff6dc35f6f9a5c9915f8d8fbb70f59f0f75490811af5a8d3459a2186aaaa

Contents?: true

Size: 608 Bytes

Versions: 1

Compression:

Stored size: 608 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 if exist?
    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

1 entries across 1 versions & 1 rubygems

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