Sha256: 73f8763f6547cc228296485ddb323f87344361440b57d4c2eca6ed478c15e6bf

Contents?: true

Size: 838 Bytes

Versions: 10

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

10 entries across 10 versions & 1 rubygems

Version Path
ro-crate-0.4.11 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.10 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.9 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.8 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.7 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.6 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.5 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.4 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.3 lib/ro_crate/model/remote_entry.rb
ro-crate-0.4.2 lib/ro_crate/model/remote_entry.rb