Class: SearchPath

Inherits:
Object
  • Object
show all
Defined in:
lib/pik/search_path.rb

Instance Method Summary collapse

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

#joinObject 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