Class: FluentCommandBuilder::Path

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*path) ⇒ Path

Returns a new instance of Path.



6
7
8
9
# File 'lib/fluent_command_builder/internal/path.rb', line 6

def initialize(*path)
  path.select! { |p| p unless p == '' }
  @path = File.join path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/fluent_command_builder/internal/path.rb', line 4

def path
  @path
end

Instance Method Details

#evaluated_pathObject



11
12
13
14
15
# File 'lib/fluent_command_builder/internal/path.rb', line 11

def evaluated_path
  return unless @path
  # evaluates variables in path e.g. %WINDIR%
  `echo #{normalised_path}`.strip
end

#normalised_pathObject



17
18
19
20
# File 'lib/fluent_command_builder/internal/path.rb', line 17

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

#to_sObject



22
23
24
# File 'lib/fluent_command_builder/internal/path.rb', line 22

def to_s
  evaluated_path
end