Class: Path

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*path) ⇒ Path

Returns a new instance of Path.



5
6
7
8
9
# File 'lib/getversion/path.rb', line 5

def initialize(*path)
  path.select! { |p| p unless p == '' }
  @path = File.join path
  @is_windows = !ENV['WINDIR'].nil?
end

Instance Attribute Details

#is_windowsObject

Returns the value of attribute is_windows.



3
4
5
# File 'lib/getversion/path.rb', line 3

def is_windows
  @is_windows
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/getversion/path.rb', line 3

def path
  @path
end

Instance Method Details

#evaluated_pathObject



11
12
13
14
# File 'lib/getversion/path.rb', line 11

def evaluated_path
  return unless @path
  `echo #{normalised_path}`.strip
end

#normalised_pathObject



16
17
18
19
# File 'lib/getversion/path.rb', line 16

def normalised_path
  return unless @path
  @is_windows ? @path.gsub('/', '\\') : @path.gsub('\\', '/')
end

#to_sObject



21
22
23
# File 'lib/getversion/path.rb', line 21

def to_s
  evaluated_path
end