Method: MemFs::IO#seek
- Defined in:
- lib/memfs/io.rb
#seek(amount, whence = ::IO::SEEK_SET) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/memfs/io.rb', line 176 def seek(amount, whence = ::IO::SEEK_SET) new_pos = case whence when ::IO::SEEK_CUR then entry.pos + amount when ::IO::SEEK_END then content.to_s.length + amount when ::IO::SEEK_SET then amount end fail Errno::EINVAL, path if new_pos.nil? || new_pos < 0 entry.pos = new_pos 0 end |