Class: Ole::Storage::DirClass::Dir

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ole/file_system.rb

Overview

note that there is nothing remotely ole specific about this class. it simply provides the dir like sequential access methods on top of an array. hmm, doesn’t throw the IOError’s on use of a closed directory…

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#group_by, #sum

Constructor Details

#initialize(path, entries) ⇒ Dir

Returns a new instance of Dir.



393
394
395
# File 'lib/ole/file_system.rb', line 393

def initialize path, entries
	@path, @entries, @pos = path, entries, 0
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



392
393
394
# File 'lib/ole/file_system.rb', line 392

def entries
  @entries
end

#pathObject (readonly)

Returns the value of attribute path.



392
393
394
# File 'lib/ole/file_system.rb', line 392

def path
  @path
end

#posObject Also known as: tell

Returns the value of attribute pos.



392
393
394
# File 'lib/ole/file_system.rb', line 392

def pos
  @pos
end

Instance Method Details

#closeObject



401
402
# File 'lib/ole/file_system.rb', line 401

def close
end

#each(&block) ⇒ Object



397
398
399
# File 'lib/ole/file_system.rb', line 397

def each(&block)
	entries.each(&block)
end

#readObject



404
405
406
407
408
# File 'lib/ole/file_system.rb', line 404

def read
	entries[pos]
ensure
	@pos += 1 if pos < entries.length
end

#rewindObject



414
415
416
# File 'lib/ole/file_system.rb', line 414

def rewind
	@pos = 0
end