Class: SearchPath
- Inherits:
-
Object
- Object
- SearchPath
- Defined in:
- lib/pik/search_path.rb
Instance Method Summary collapse
- #add(new) ⇒ Object
-
#initialize(path) ⇒ SearchPath
constructor
A new instance of SearchPath.
- #join ⇒ Object (also: #to_s)
- #replace(old, new) ⇒ Object
- #replace_or_add(old, new) ⇒ Object
Constructor Details
#initialize(path) ⇒ SearchPath
Returns a new instance of SearchPath.
4 5 6 |
# File 'lib/pik/search_path.rb', line 4 def initialize(path) @path = path.split(';') end |
Instance Method Details
#add(new) ⇒ Object
20 21 22 23 |
# File 'lib/pik/search_path.rb', line 20 def add(new) @path << new self end |
#join ⇒ Object Also known as: to_s
32 33 34 |
# File 'lib/pik/search_path.rb', line 32 def join @path.join(';') end |
#replace(old, new) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pik/search_path.rb', line 8 def replace(old, new) @path.map!{|dir| case dir when old new else dir end }.uniq! self end |
#replace_or_add(old, new) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/pik/search_path.rb', line 25 def replace_or_add(old, new) old_path = @path.dup replace(old, new) add(new) if @path == old_path self end |