Class: Vnstat::Traffic::Hourly

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

Overview

A class encapsulating hourly 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, hour) ⇒ Result::Hour #[](year, month, day, hour) ⇒ Result::Hour

Fetches a single Result::Hour from the collection.

Overloads:

  • #[](date, hour) ⇒ Result::Hour

    Parameters:

    • date (Date)
    • hour (Integer)
  • #[](year, month, day, hour) ⇒ Result::Hour

    Parameters:

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

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vnstat/traffic/hourly.rb', line 22

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