Class: ROCrate::RemoteEntry

Inherits:
Entry
  • Object
show all
Defined in:
lib/ro_crate/model/remote_entry.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Entry

#path, #read, #write_to

Constructor Details

#initialize(uri, directory: false) ⇒ RemoteEntry

Create a new RemoteEntry.

Parameters:

  • uri (URI)

    An absolute URI.



12
13
14
15
# File 'lib/ro_crate/model/remote_entry.rb', line 12

def initialize(uri, directory: false)
  @uri = uri
  @directory = directory
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/ro_crate/model/remote_entry.rb', line 6

def uri
  @uri
end

Instance Method Details

#directory?Boolean

Does this RemoteEntry point to a directory

Returns:

  • (Boolean)


26
27
28
# File 'lib/ro_crate/model/remote_entry.rb', line 26

def directory?
  @directory
end

#remote?Boolean

Does this RemoteEntry point to a remote resource?

Returns:

  • (Boolean)


38
39
40
# File 'lib/ro_crate/model/remote_entry.rb', line 38

def remote?
  true
end

#sourceIO

Returns An IO object for the remote resource.

Returns:

  • (IO)

    An IO object for the remote resource.



20
21
22
# File 'lib/ro_crate/model/remote_entry.rb', line 20

def source
  uri.open
end

#symlink?Boolean

Does this RemoteEntry point to a symlink

Returns:

  • (Boolean)


32
33
34
# File 'lib/ro_crate/model/remote_entry.rb', line 32

def symlink?
  false
end