Class: RubySMB::Server::Share::Provider::VirtualDisk::VirtualStaticFile
- Inherits:
-
VirtualPathname
- Object
- VirtualPathname
- RubySMB::Server::Share::Provider::VirtualDisk::VirtualStaticFile
- Defined in:
- lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb
Overview
A static file is one whose contents are known at creation time and do not change.
Constant Summary
Constants inherited from VirtualPathname
RubySMB::Server::Share::Provider::VirtualDisk::VirtualPathname::SEPARATOR
Instance Attribute Summary collapse
- #content ⇒ Object readonly
Attributes inherited from VirtualPathname
Instance Method Summary collapse
-
#initialize(disk, path, content, stat: nil) ⇒ VirtualStaticFile
constructor
A new instance of VirtualStaticFile.
- #open(mode = 'r', &block) ⇒ Object
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, content, stat: nil) ⇒ VirtualStaticFile
Returns a new instance of VirtualStaticFile.
36 37 38 39 40 41 42 |
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 36 def initialize(disk, path, content, stat: nil) stat = stat || VirtualStat.new(file?: true, size: content.size) raise ArgumentError.new('stat is not a file') unless stat.file? @content = content 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 Attribute Details
#content ⇒ Object (readonly)
49 50 51 |
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 49 def content @content end |
Instance Method Details
#open(mode = 'r', &block) ⇒ Object
44 45 46 47 |
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 44 def open(mode = 'r', &block) file = StringIO.new(@content) block_given? ? block.call(file) : file end |