class Vnstat::Traffic::Monthly

A class encapsulating monthly tracking information.

Public Instance Methods

[](year, month) click to toggle source

Fetches a single {Result::Month} from the collection.

@param [Integer] year @param [Integer] month @return [Result::Month]

# File lib/vnstat/traffic/monthly.rb, line 14
def [](year, month)
  entries_hash[[year, month]]
end

Private Instance Methods

entries_hash() click to toggle source
# File lib/vnstat/traffic/monthly.rb, line 20
def entries_hash
  elements = traffic_data.xpath('months/month')
  elements.each_with_object({}) do |element, hash|
    result = Result::Month.extract_from_xml_element(element)
    hash[[result.year, result.month]] = result
  end
end