Module: Monkey::Ext::Pathname
- Defined in:
- lib/monkey/ext/pathname.rb
Instance Method Summary collapse
-
#cased_path ⇒ Pathname, NilClass
Path with correct casing.
- #chdir(&block) ⇒ Object
- #open(mode = "r", &block) ⇒ Object
Instance Method Details
#cased_path ⇒ Pathname, NilClass
Returns Path with correct casing.
8 9 10 11 12 13 |
# File 'lib/monkey/ext/pathname.rb', line 8 def cased_path return unless exist? return Dir.chdir(self) { Pathname(Dir.pwd) } if ::File.directory? path files = Dir.chdir(dirname) { Dir.entries('.').select { |f| f.downcase == basename.to_s.downcase } } dirname.cased_path.join(files.size == 1 ? files.first : basename) end |
#chdir(&block) ⇒ Object
15 16 17 |
# File 'lib/monkey/ext/pathname.rb', line 15 def chdir(&block) Dir.chdir(self.to_s, &block) end |