Class: TorqueBox::VFS::Dir
- Inherits:
-
Object
- Object
- TorqueBox::VFS::Dir
- Defined in:
- lib/torquebox/vfs/dir.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#pos ⇒ Object
(also: #tell)
Returns the value of attribute pos.
Instance Method Summary collapse
- #close ⇒ Object
- #each ⇒ Object
- #entries ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(path) ⇒ Dir
constructor
A new instance of Dir.
- #read ⇒ Object
- #rewind ⇒ Object
- #seek(i) ⇒ Object
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
#path ⇒ Object (readonly)
Returns the value of attribute path.
21 22 23 |
# File 'lib/torquebox/vfs/dir.rb', line 21 def path @path end |
#pos ⇒ Object 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
#close ⇒ Object
36 37 38 |
# File 'lib/torquebox/vfs/dir.rb', line 36 def close @closed = true end |
#each ⇒ Object
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 |
#entries ⇒ Object
67 68 69 |
# File 'lib/torquebox/vfs/dir.rb', line 67 def entries [ '.', '..' ] + @virtual_file.children.map(&:name) end |
#exists? ⇒ Boolean
71 72 73 |
# File 'lib/torquebox/vfs/dir.rb', line 71 def exists? @virtual_file.exists? end |
#read ⇒ Object
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 |
#rewind ⇒ Object
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 |