Class: IRODS4r::File

Inherits:
Object
  • Object
show all
Defined in:
lib/irods4r/file.rb

Overview

This class proxies a file in an iRODS environment

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



48
49
50
# File 'lib/irods4r/file.rb', line 48

def path
  @path
end

Class Method Details

.create(path, must_not_exist = true, opts = {}) ⇒ Object

Create a file resource ‘path’. If ‘must_not_exist’ is true, throw exception if resource already exists.



17
18
19
20
21
22
# File 'lib/irods4r/file.rb', line 17

def self.create(path, must_not_exist = true, opts = {})
  if must_not_exist
    raise FileExistsException.new(path) if ICommands.exist?(path)
  end
  self.new(path, opts)
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/irods4r/file.rb', line 44

def directory?
  return false
end

#file?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/irods4r/file.rb', line 40

def file?
  return true
end

#readObject

Return the content of this file



26
27
28
# File 'lib/irods4r/file.rb', line 26

def read()
  ICommands.read(@path, @ticket)
end

#write(content) ⇒ Object

Write content to this file.

WARN: This will overwrite any previous content



34
35
36
37
38
# File 'lib/irods4r/file.rb', line 34

def write(content)
  dir_name = ::File.dirname(@path)
  ICommands.mkpath(dir_name) unless IRODS4r.exists?(dir_name)
  ICommands.write(@path, content, @ticket)
end