Method: Utilities#dos_path
- Defined in:
- lib/utilities.rb
#dos_path(source_path, drive_letter = "C") ⇒ Object
Returns the dos path from a standard path
Attributes
-
source_path
- path in standard “/” format -
drive_letter
- base drive letter if not included in path (defaults to C)
Returns
-
dos compatible path
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/utilities.rb', line 17 def dos_path(source_path, drive_letter = "C") path = "" return source_path.gsub("/", "\\") if source_path.include?(":\\") path_array = source_path.split("/") if path_array[1].length == 1 # drive letter path = "#{path_array[1]}:\\" path += path_array[2..-1].join("\\") else path = "#{drive_letter}:\\" path += path_array[1..-1].join("\\") end path end |