Class: Ole::Storage::DirClass::Dir
- Inherits:
-
Object
- Object
- Ole::Storage::DirClass::Dir
- Includes:
- Enumerable
- Defined in:
- lib/ole/storage/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.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #close ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(path, entries) ⇒ Dir
constructor
A new instance of Dir.
- #pos ⇒ Object (also: #tell)
- #pos=(pos) ⇒ Object (also: #seek)
- #read ⇒ Object
- #rewind ⇒ Object
Methods included from Enumerable
Constructor Details
#initialize(path, entries) ⇒ Dir
Returns a new instance of Dir.
354 355 356 357 |
# File 'lib/ole/storage/file_system.rb', line 354 def initialize path, entries @path, @entries, @pos = path, entries, 0 @closed = false end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
353 354 355 |
# File 'lib/ole/storage/file_system.rb', line 353 def path @path end |
Instance Method Details
#close ⇒ Object
369 370 371 |
# File 'lib/ole/storage/file_system.rb', line 369 def close @closed = true end |
#each(&block) ⇒ Object
364 365 366 367 |
# File 'lib/ole/storage/file_system.rb', line 364 def each(&block) raise IOError if @closed @entries.each(&block) end |
#pos ⇒ Object Also known as: tell
359 360 361 362 |
# File 'lib/ole/storage/file_system.rb', line 359 def pos raise IOError if @closed @pos end |
#pos=(pos) ⇒ Object Also known as: seek
380 381 382 383 |
# File 'lib/ole/storage/file_system.rb', line 380 def pos= pos raise IOError if @closed @pos = [[0, pos].max, @entries.length].min end |
#read ⇒ Object
373 374 375 376 377 378 |
# File 'lib/ole/storage/file_system.rb', line 373 def read raise IOError if @closed @entries[pos] ensure @pos += 1 if pos < @entries.length end |
#rewind ⇒ Object
387 388 389 |
# File 'lib/ole/storage/file_system.rb', line 387 def rewind seek 0 end |