Class: RubySMB::Server::Share::Provider::VirtualDisk::VirtualDynamicFile

Inherits:
VirtualPathname
  • Object
show all
Defined in:
lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb

Overview

A dynamic file is one whose contents are generated by the specified block.

Since:

  • 3.1.1

Constant Summary

Constants inherited from VirtualPathname

RubySMB::Server::Share::Provider::VirtualDisk::VirtualPathname::SEPARATOR

Instance Attribute Summary

Attributes inherited from VirtualPathname

#virtual_disk

Instance Method Summary collapse

Methods inherited from VirtualPathname

#<=>, #==, #absolute?, #basename, basename, #children, #cleanpath, cleanpath, dirname, #dirname, #entries, #exist?, #extname, #join, #relative?, #split, #stat, #to_s

Constructor Details

#initialize(disk, path, stat: nil, &block) ⇒ VirtualDynamicFile

Returns a new instance of VirtualDynamicFile.

Parameters:

  • disk (Hash)

    The mapping of paths to objects representing the virtual file system.

  • path (String)

    The path of this entry.

  • stat (File::Stat) (defaults to: nil)

    An explicit stat object describing the file.

Raises:

  • (ArgumentError)

Since:

  • 3.1.1



15
16
17
18
19
20
21
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 15

def initialize(disk, path, stat: nil, &block)
  raise ArgumentError.new('a generation block must be specified') if block.nil?

  @content_generator = block
  super(disk, path)
  @stat = stat
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RubySMB::Server::Share::Provider::VirtualDisk::VirtualPathname

Instance Method Details

#generate(server_client, session) ⇒ Object

Since:

  • 3.1.1



23
24
25
26
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 23

def generate(server_client, session)
  content = @content_generator.call(server_client, session)
  VirtualStaticFile.new(@virtual_disk, @path, content, stat: @stat)
end