Class: Disloku::Util::File
- Inherits:
-
Object
- Object
- Disloku::Util::File
- Defined in:
- lib/disloku/util/File.rb
Instance Attribute Summary collapse
-
#change ⇒ Object
Returns the value of attribute change.
-
#srcPath ⇒ Object
Returns the value of attribute srcPath.
Class Method Summary collapse
Instance Method Summary collapse
- #getAbsoluteDstPath(basePath = nil) ⇒ Object
- #getRelativeDirSegments ⇒ Object
- #getRelativeDstSegments ⇒ Object
- #hasMapping? ⇒ Boolean
-
#initialize(filePath, basePath, target, change) ⇒ File
constructor
A new instance of File.
- #to_s ⇒ Object
Constructor Details
#initialize(filePath, basePath, target, change) ⇒ File
Returns a new instance of File.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/disloku/util/File.rb', line 18 def initialize(filePath, basePath, target, change) @srcPath = filePath @target = target @change = change fileSegments = File.getSegments(filePath) baseSegments = File.getSegments(basePath) index = 0 while (fileSegments[index] == baseSegments[index]) index += 1 end @relativeSrcSegments = fileSegments[index..-1] @relativeDstSegments = target.mapPath(@relativeSrcSegments) end |
Instance Attribute Details
#change ⇒ Object
Returns the value of attribute change.
16 17 18 |
# File 'lib/disloku/util/File.rb', line 16 def change @change end |
#srcPath ⇒ Object
Returns the value of attribute srcPath.
16 17 18 |
# File 'lib/disloku/util/File.rb', line 16 def srcPath @srcPath end |
Class Method Details
.getSegments(path) ⇒ Object
12 13 14 |
# File 'lib/disloku/util/File.rb', line 12 def self.getSegments(path) return path.split(/#{SPLIT_EXP}/) end |
Instance Method Details
#getAbsoluteDstPath(basePath = nil) ⇒ Object
46 47 48 49 |
# File 'lib/disloku/util/File.rb', line 46 def getAbsoluteDstPath(basePath = nil) basePath = basePath || @target.targetDir return ::File.join(basePath, *@relativeDstSegments) end |
#getRelativeDirSegments ⇒ Object
38 39 40 |
# File 'lib/disloku/util/File.rb', line 38 def getRelativeDirSegments() return @segments[0..-2] end |
#getRelativeDstSegments ⇒ Object
34 35 36 |
# File 'lib/disloku/util/File.rb', line 34 def getRelativeDstSegments() return @segments end |
#hasMapping? ⇒ Boolean
42 43 44 |
# File 'lib/disloku/util/File.rb', line 42 def hasMapping?() return @relativeDstSegments != nil end |
#to_s ⇒ Object
51 52 53 54 |
# File 'lib/disloku/util/File.rb', line 51 def to_s() operation = (@change.changeType == :deleted ? "x>" : "->") return "#{srcPath} #{operation} #{getAbsoluteDstPath()}" end |