Sha256: 2b03119155140da964ab6d0b40086d3a9ea65c52a91bb90d86216a549d3e8474

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

module VirtFS::CamcorderFS # rubocop:disable Style/ClassAndModuleChildren
  #
  # CamcorderFS::Dir class.
  # Instance methods call into CamcorderFS::FS instance.
  #
  class Dir
    attr_reader :fs

    NS_PFX = "dir_i_"

    def initialize(fs, instance_handle, hash_args)
      @fs              = fs
      @instance_handle = instance_handle
      @hash_args       = hash_args
      @cache           = nil
    end

    def close
      fs_call(__method__)
    end

    # returns file_name and new position.
    def read(pos)
      return cache[pos], pos + 1
    end

    private

    def cache
      @cache ||= fs_call(:each, nil, nil).to_a
    end

    def fs_call(method, *args)
      @fs.send("#{NS_PFX}#{method}", @instance_handle, *args)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
virtfs-camcorderfs-0.0.1 lib/virtfs/camcorderfs/dir.rb