Class: TorqueBox::VFS::Dir

Inherits:
Object
  • Object
show all
Defined in:
lib/torquebox/vfs/dir.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Dir

Returns a new instance of Dir.



25
26
27
28
29
30
31
32
33
34
# File 'lib/torquebox/vfs/dir.rb', line 25

def initialize(path)
  @path         = path
  begin
    @virtual_file = org.jboss.vfs.VFS.child( path )
  rescue Java::JavaLang::NullPointerException
    raise Errno::ENOENT.new
  end
  @pos          = 0
  @closed       = false
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



21
22
23
# File 'lib/torquebox/vfs/dir.rb', line 21

def path
  @path
end

#posObject Also known as: tell

Returns the value of attribute pos.



22
23
24
# File 'lib/torquebox/vfs/dir.rb', line 22

def pos
  @pos
end

Instance Method Details

#closeObject



36
37
38
# File 'lib/torquebox/vfs/dir.rb', line 36

def close
  @closed = true
end

#eachObject



40
41
42
43
44
# File 'lib/torquebox/vfs/dir.rb', line 40

def each
  @virtual_file.children.each do |child|
    yield child.name
  end
end

#entriesObject



67
68
69
# File 'lib/torquebox/vfs/dir.rb', line 67

def entries
  [ '.', '..' ] + @virtual_file.children.map(&:name)
end

#exists?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/torquebox/vfs/dir.rb', line 71

def exists?
  @virtual_file.exists?
end

#readObject



50
51
52
53
54
55
56
# File 'lib/torquebox/vfs/dir.rb', line 50

def read
  children = @virtual_file.children
  return nil unless ( @pos < children.size )
  child = children[@pos]
  @pos += 1
  child.name
end

#rewindObject



46
47
48
# File 'lib/torquebox/vfs/dir.rb', line 46

def rewind
  @pos = 0
end

#seek(i) ⇒ Object



58
59
60
61
# File 'lib/torquebox/vfs/dir.rb', line 58

def seek(i)
  @pos = i
  self
end