Class: MyPath::Handler
- Inherits:
-
Object
- Object
- MyPath::Handler
- Defined in:
- lib/mypath/handler.rb,
lib/mypath/handler/cwd.rb,
lib/mypath/handler/gem.rb
Defined Under Namespace
Class Attribute Summary collapse
-
.list ⇒ Object
Returns the value of attribute list.
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(path) ⇒ Handler
Returns a new instance of Handler.
26 27 28 |
# File 'lib/mypath/handler.rb', line 26 def initialize(path) self.path = self.class.clean_path(path) end |
Class Attribute Details
.list ⇒ Object
Returns the value of attribute list.
5 6 7 |
# File 'lib/mypath/handler.rb', line 5 def list @list end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
24 25 26 |
# File 'lib/mypath/handler.rb', line 24 def path @path end |
Class Method Details
.clean_path(path) ⇒ Object
11 12 13 |
# File 'lib/mypath/handler.rb', line 11 def clean_path(path) path.gsub(/:.*/, "") end |
.for(path) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/mypath/handler.rb', line 15 def for(path) handler = self.list.detect{|h| h.can_handle?(path)} if handler handler.new(path) end end |
.inherited(klass) ⇒ Object
7 8 9 |
# File 'lib/mypath/handler.rb', line 7 def inherited(klass) self.list |= [klass] end |