Class: Vnstat::Configuration

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

Overview

A class encapsulating configurations of the Vnstat environment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Initializes the Vnstat::Configuration.



12
13
14
# File 'lib/vnstat/configuration.rb', line 12

def initialize
  reset
end

Instance Attribute Details

#executable_pathString

Returns the location of the vnstat executable.

Returns:

  • (String)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vnstat/configuration.rb', line 9

class Configuration
  ##
  # Initializes the {Configuration}.
  def initialize
    reset
  end

  ##
  # Restores the configuration defaults.
  #
  # @return [Configuration]
  def reset
    @executable_path = nil
    self
  end

  ##
  # Returns the location of the vnstat executable.
  #
  # @return [String]
  def executable_path
    @executable_path ||= Utils.system_call('which', 'vnstat') do
      raise ExecutableNotFound, 'Unable to locate vnstat executable'
    end
  end

  attr_writer :executable_path
end

Instance Method Details

#resetConfiguration

Restores the configuration defaults.

Returns:



20
21
22
23
# File 'lib/vnstat/configuration.rb', line 20

def reset
  @executable_path = nil
  self
end