Class: ROCrate::RemoteEntry

Inherits:
Object
  • 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

Constructor Details

#initialize(uri) ⇒ RemoteEntry

Create a new RemoteEntry.

Parameters:

  • uri (URI)

    An absolute URI.



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

def initialize(uri)
  @uri = uri
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 on the disk?

Returns:

  • (Boolean)


36
37
38
# File 'lib/ro_crate/model/remote_entry.rb', line 36

def directory?
  false
end

#readObject

Read from the source.



23
24
25
# File 'lib/ro_crate/model/remote_entry.rb', line 23

def read
  source.read
end

#remote?Boolean

Does this RemoteEntry point to a remote resource?

Returns:

  • (Boolean)


42
43
44
# File 'lib/ro_crate/model/remote_entry.rb', line 42

def remote?
  true
end

#sourceIO

Returns An IO object for the remote resource.

Returns:

  • (IO)

    An IO object for the remote resource.



30
31
32
# File 'lib/ro_crate/model/remote_entry.rb', line 30

def source
  open(uri)
end

#write(dest) ⇒ Object



16
17
18
# File 'lib/ro_crate/model/remote_entry.rb', line 16

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