Sha256: ae1009dcdc1f43d7adeb50c7217476268419a6b72a638f14a7d16f91615f0673

Contents?: true

Size: 899 Bytes

Versions: 7

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

module Vnstat
  module Traffic
    ##
    # An abstract implementation for a traffic collection.
    #
    # @attr_reader [Interface] interface The tracked interface.
    class Base
      include Enumerable

      attr_reader :interface

      ##
      # Initializes the traffic collection.
      #
      # @param [Interface] interface The tracked interface.
      def initialize(interface)
        @interface = interface
      end

      ##
      # Iterates over all results in the collection.
      #
      # @overload each
      #   @return [Enumerator]
      #
      # @overload each(&block)
      #   @yield [result]
      #   @yieldparam [Result] result
      #   @return [Base]
      def each(&block)
        entries_hash.values.each(&block)
      end

      private

      def traffic_data
        interface.data.xpath('//traffic')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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