Module: Duby::Env
- Defined in:
- lib/duby/env.rb
Class Method Summary collapse
-
.decode_paths(paths, dest = nil) ⇒ Object
Takes a single string value “paths” and returns an array of strings containing the original string separated using the path_separator.
-
.encode_paths(paths) ⇒ Object
Takes an array of strings and joins them using the path_separator returning a single string value.
-
.path_seperator ⇒ Object
Returns the system PATH_SEPARATOR environment variable value.
Class Method Details
.decode_paths(paths, dest = nil) ⇒ Object
Takes a single string value “paths” and returns an array of strings containing the original string separated using the path_separator. An option second parameter is an array that will have the strings appended to it. If the optional array parameter is supplied it is returned as the result
25 26 27 28 29 30 31 |
# File 'lib/duby/env.rb', line 25 def self.decode_paths(paths, dest = nil) result = dest ? dest : [] paths.split(path_seperator).each do |path| result << path end result end |
.encode_paths(paths) ⇒ Object
Takes an array of strings and joins them using the path_separator returning a single string value
17 18 19 |
# File 'lib/duby/env.rb', line 17 def self.encode_paths(paths) paths.join(path_seperator) end |
.path_seperator ⇒ Object
Returns the system PATH_SEPARATOR environment variable value. This is used when separating multiple paths in one string. If none is defined then a : (colon) is returned
9 10 11 12 13 |
# File 'lib/duby/env.rb', line 9 def self.path_seperator ps = RbConfig::CONFIG['PATH_SEPARATOR'] ps = ':' if ps.nil? || ps == '' ps end |