Class: MockFS::DirAdapter
- Inherits:
-
Object
- Object
- MockFS::DirAdapter
- Extended by:
- Adapter
- Includes:
- Adapter
- Defined in:
- lib/mockfs.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
- .[](string) ⇒ Object
- .foreach(dirname, &block) ⇒ Object
- .glob(string, flags = 0) ⇒ Object
- .mkdir(dirname) ⇒ Object
- .rmdir(dirname) ⇒ Object
Instance Method Summary collapse
- #entries ⇒ Object
-
#initialize(dirname) ⇒ DirAdapter
constructor
A new instance of DirAdapter.
Methods included from Adapter
method_missing, node, respond_to?
Constructor Details
#initialize(dirname) ⇒ DirAdapter
Returns a new instance of DirAdapter.
190 191 192 193 194 195 |
# File 'lib/mockfs.rb', line 190 def initialize( dirname ) unless node( dirname ).class == MockFileSystem::MockDir raise Errno::ENOTDIR end @path = dirname end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MockFS::Adapter
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
188 189 190 |
# File 'lib/mockfs.rb', line 188 def path @path end |
Class Method Details
.[](string) ⇒ Object
166 |
# File 'lib/mockfs.rb', line 166 def self.[]( string ); glob( string, 0 ); end |
.foreach(dirname, &block) ⇒ Object
168 169 170 |
# File 'lib/mockfs.rb', line 168 def self.foreach( dirname, &block ) entries( dirname ).each( &block ) end |
.glob(string, flags = 0) ⇒ Object
172 173 174 175 176 |
# File 'lib/mockfs.rb', line 172 def self.glob( string, flags = 0 ) DirAdapter.new( '.' ).send( :glob, string, flags ).map { |result| Path.new( result )[1..-1] } end |
Instance Method Details
#entries ⇒ Object
197 |
# File 'lib/mockfs.rb', line 197 def entries; self.class.entries( @path ); end |