Class: VirtualFS::File
- Inherits:
-
Object
show all
- Defined in:
- lib/virtualfs/file.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path, backend) ⇒ File
Returns a new instance of File.
5
6
7
8
|
# File 'lib/virtualfs/file.rb', line 5
def initialize(path, backend)
@path = VirtualFS.realpath(path)
@backend = backend
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
18
19
20
21
|
# File 'lib/virtualfs/file.rb', line 18
def method_missing(method, *args)
@stream ||= @backend.stream_for(@path)
@stream.send(method, *args)
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
3
4
5
|
# File 'lib/virtualfs/file.rb', line 3
def path
@path
end
|
Instance Method Details
#directory? ⇒ Boolean
14
15
16
|
# File 'lib/virtualfs/file.rb', line 14
def directory?
false
end
|
#inspect ⇒ Object
23
24
25
|
# File 'lib/virtualfs/file.rb', line 23
def inspect
"<#{@backend.class.name} '#{@path}'>"
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/virtualfs/file.rb', line 10
def name
@path.rpartition('/').last
end
|