Sha256: 7f15a344a319cc3e89815ee10b311c19ef491b07220f7256700a81a415a79c51

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

module ROCrate
  ##
  # A class to represent a reference within an RO crate, to a remote file held on the internet somewhere.
  # It handles the actual reading/writing of bytes.
  class RemoteEntry
    attr_reader :uri

    ##
    # Create a new RemoteEntry.
    #
    # @param uri [URI] An absolute URI.
    def initialize(uri)
      @uri = uri
    end

    def write(dest)
      raise 'Cannot write to a remote entry!'
    end

    ##
    # Read from the source.
    #
    def read
      source.read
    end

    ##
    # @return [IO] An IO object for the remote resource.
    #
    def source
      open(uri)
    end

    ##
    # Does this RemoteEntry point to a directory on the disk?
    def directory?
      false
    end

    ##
    # Does this RemoteEntry point to a remote resource?
    def remote?
      true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ro-crate-0.4.1 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.0 lib/ro_crate/model/remote_entry.rb