Class: Util

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

Class Method Summary collapse

Class Method Details

.makeAbsolute(file, pwd) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/Util.rb', line 9

def self.makeAbsolute(file, pwd)
  if File.isAbsolute?(file)
    outputfilename = file
  else
    #outputfilename = File.dirname(pwd) + "/" + file
    outputfilename = File.expand_path(file)
  end
  return outputfilename    
end

.strToArray(key, map) ⇒ Object



19
20
21
# File 'lib/Util.rb', line 19

def self.strToArray(key, map)
  map[key][1..-2].split(",").map {|elem| elem.strip}
end

.truncateStr(refStr, toTruncStr) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Util.rb', line 23

def self.truncateStr(refStr, toTruncStr)
  posOfSlash = refStr.index("/")
  while posOfSlash != nil && toTruncStr[0..1] != ".."
    if refStr[0..posOfSlash] == toTruncStr[0..posOfSlash]
      toTruncStr = toTruncStr[posOfSlash+1..-1]
      refStr = refStr[posOfSlash+1..-1]
    else
      break
    end
    posOfSlash = refStr.index("/")
  end
  return toTruncStr
end