Class: MyPath::Handler::CWD

Inherits:
MyPath::Handler show all
Defined in:
lib/mypath/handler/cwd.rb

Instance Attribute Summary

Attributes inherited from MyPath::Handler

#path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MyPath::Handler

clean_path, for, inherited, #initialize

Constructor Details

This class inherits a constructor from MyPath::Handler

Class Method Details

.can_handle?(path) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
# File 'lib/mypath/handler/cwd.rb', line 4

def self.can_handle?(path)
  parts = path.split("/")
  !Dir[*parts].empty?
end

Instance Method Details

#local_pathObject



9
10
11
12
13
14
15
16
# File 'lib/mypath/handler/cwd.rb', line 9

def local_path
  parts = path.split("/")
  rejoined = []
  parts.each_with_index do |part, index|
    rejoined << parts[index..-1].join("/")
  end
  local = Dir[*rejoined].first
end