Sha256: 957f56f811696c51f369da7a1a182bf044bb9ef112346f2921040c7928a830a8

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'rubygems'
require 'vnstat/version'
require 'time'

##
# The Vnstat namespace.
module Vnstat
  autoload :Configuration, 'vnstat/configuration'
  autoload :Document, 'vnstat/document'
  autoload :Interface, 'vnstat/interface'
  autoload :InterfaceCollection, 'vnstat/interface_collection'
  autoload :Parser, 'vnstat/parser'
  autoload :Result, 'vnstat/result'
  autoload :Traffic, 'vnstat/traffic'
  autoload :Utils, 'vnstat/utils'

  autoload :Error, 'vnstat/error'
  autoload :ExecutableNotFound, 'vnstat/errors/executable_not_found'
  autoload :UnknownInterface, 'vnstat/errors/unknown_interface'

  module_function

  ##
  # The configuration of the Vnstat environment.
  #
  # @return [Configuration]
  def config
    @config ||= Configuration.new
  end

  ##
  # Configures the Vnstat environment.
  #
  # @yieldparam [Configuration] config The environment configuration.
  # @return [Configuration]
  def configure
    yield(config)
    config
  end

  ##
  # Returns traffic information for the given interface.
  #
  # @param [String] id The network interface identifier.
  # @return [Interface]
  def [](id)
    interfaces[id]
  end

  ##
  # Returns traffic information for all known interfaces.
  #
  # @return [InterfaceCollection]
  def interfaces
    InterfaceCollection.open
  end

  ##
  # Returns information for the currently installed version of vnstat.
  #
  # @return [String]
  def cli_version
    Utils.call_executable('-v')
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vnstat-ruby-3.0.7 lib/vnstat.rb
vnstat-ruby-3.0.6 lib/vnstat.rb
vnstat-ruby-3.0.5 lib/vnstat.rb
vnstat-ruby-3.0.4 lib/vnstat.rb
vnstat-ruby-3.0.2 lib/vnstat.rb
vnstat-ruby-3.0.0 lib/vnstat.rb