Class: GlusterFS::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/glusterfs/directory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(volume, path) ⇒ Directory

Returns a new instance of Directory.



3
4
5
6
# File 'lib/glusterfs/directory.rb', line 3

def initialize(volume, path)
  @volume = volume
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



2
3
4
# File 'lib/glusterfs/directory.rb', line 2

def path
  @path
end

#volumeObject (readonly)

Returns the value of attribute volume.



2
3
4
# File 'lib/glusterfs/directory.rb', line 2

def volume
  @volume
end

Instance Method Details

#create(perms = 0755) ⇒ Object



8
9
10
# File 'lib/glusterfs/directory.rb', line 8

def create(perms = 0755)
  GlusterFS.mkdir(@volume.fs, @path, perms)
end

#deleteObject



12
13
14
# File 'lib/glusterfs/directory.rb', line 12

def delete
  GlusterFS.rmdir(@volume.fs, @path)
end

#exists?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/glusterfs/directory.rb', line 22

def exists?
  lstat[:st_size] > 0
end

#lstatObject



16
17
18
19
20
# File 'lib/glusterfs/directory.rb', line 16

def lstat
  data = GlusterFS::Stat.new
  GlusterFS.lstat(@volume.fs, @path, data)
  data
end