Module: MemFs::IO::ClassMethods
- Included in:
- File
- Defined in:
- lib/memfs/io.rb
Instance Method Summary collapse
Instance Method Details
#read(path, *args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/memfs/io.rb', line 7 def read(path, *args) = args.last.is_a?(Hash) ? args.pop : {} = { mode: File::RDONLY, encoding: nil, open_args: nil }.merge() open_args = [:open_args] || [[:mode], encoding: [:encoding]] length, offset = args file = open(path, *open_args) file.seek(offset || 0) file.read(length) ensure file.close if file end |