Class: Path
- Inherits:
-
Object
- Object
- Path
- Defined in:
- lib/getversion/path.rb
Instance Attribute Summary collapse
-
#is_windows ⇒ Object
Returns the value of attribute is_windows.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #evaluated_path ⇒ Object
-
#initialize(*path) ⇒ Path
constructor
A new instance of Path.
- #normalised_path ⇒ Object
- #to_s ⇒ Object
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_windows ⇒ Object
Returns the value of attribute is_windows.
3 4 5 |
# File 'lib/getversion/path.rb', line 3 def is_windows @is_windows end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/getversion/path.rb', line 3 def path @path end |
Instance Method Details
#evaluated_path ⇒ Object
11 12 13 14 |
# File 'lib/getversion/path.rb', line 11 def evaluated_path return unless @path `echo #{normalised_path}`.strip end |
#normalised_path ⇒ Object
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_s ⇒ Object
21 22 23 |
# File 'lib/getversion/path.rb', line 21 def to_s evaluated_path end |