Class: VirtualFS::Dir
- Inherits:
-
Object
- Object
- VirtualFS::Dir
- Includes:
- Enumerable
- Defined in:
- lib/virtualfs/dir.rb
Instance Method Summary collapse
- #directory? ⇒ Boolean
- #each(&block) ⇒ Object
- #entries ⇒ Object
- #glob(pattern) ⇒ Object (also: #[])
-
#initialize(path, backend) ⇒ Dir
constructor
A new instance of Dir.
- #inspect ⇒ Object
- #name ⇒ Object
- #path ⇒ Object
Constructor Details
Instance Method Details
#directory? ⇒ Boolean
20 21 22 |
# File 'lib/virtualfs/dir.rb', line 20 def directory? true end |
#each(&block) ⇒ Object
32 33 34 |
# File 'lib/virtualfs/dir.rb', line 32 def each(&block) entries.each(&block) end |
#entries ⇒ Object
24 25 26 |
# File 'lib/virtualfs/dir.rb', line 24 def entries @backend.entries @realpath end |
#glob(pattern) ⇒ Object Also known as: []
28 29 30 |
# File 'lib/virtualfs/dir.rb', line 28 def glob(pattern) @backend.glob pattern, @realpath end |
#inspect ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/virtualfs/dir.rb', line 36 def inspect if ['.','..'].include? name p = @path else p = @realpath end "<#{@backend.class.name} '#{p}' (dir)>" end |
#name ⇒ Object
15 16 17 18 |
# File 'lib/virtualfs/dir.rb', line 15 def name name = @path.rpartition('/').last name.empty? ? '/' : name end |
#path ⇒ Object
11 12 13 |
# File 'lib/virtualfs/dir.rb', line 11 def path @realpath end |