Class: Vnstat::Traffic::Daily

Inherits:
Base
  • Object
show all
Defined in:
lib/vnstat/traffic/daily.rb

Overview

A class encapsulating daily tracking information.

Instance Attribute Summary

Attributes inherited from Base

#interface

Instance Method Summary collapse

Methods inherited from Base

#each, #initialize

Constructor Details

This class inherits a constructor from Vnstat::Traffic::Base

Instance Method Details

#[](date) ⇒ Result::Day #[](year, month, day) ⇒ Result::Day

Fetches a single Result::Day from the collection.

Overloads:

  • #[](date) ⇒ Result::Day

    Parameters:

    • date (Date)
  • #[](year, month, day) ⇒ Result::Day

    Parameters:

    • year (Integer)
    • month (Integer)
    • day (Integer)

Returns:



20
21
22
23
24
25
26
27
28
29
# File 'lib/vnstat/traffic/daily.rb', line 20

def [](*args)
  date = case args.count
         when 1 then args.first
         when 3 then Date.new(*args)
         else
           raise ArgumentError, 'wrong number of arguments ' \
                               "(#{args.count} for 1 or 3)"
         end
  entries_hash[date]
end