class Vnstat::Result::Day

A class representing a tracking result for a specific day.

@!attribute [r] date

@return [Date] The date the result was captured on.

Attributes

date[R]

Public Class Methods

extract_from_xml_element(element) click to toggle source

Initializes a {Day} using the the data contained in the given XML element.

@param [Nokogiri::XML::Element] element The XML element. @return [Day]

# File lib/vnstat/result/day.rb, line 32
def self.extract_from_xml_element(element)
  new(
    Parser.extract_date_from_xml_element(element),
    *Parser.extract_transmitted_bytes_from_xml_element(element)
  )
end
new(date, bytes_received, bytes_sent) click to toggle source

Initializes the {Day}.

@param [Date] date The date the result was captured on. @param [Integer] bytes_received The received bytes. @param [Integer] bytes_sent The sent bytes.

Calls superclass method Vnstat::Result::new
# File lib/vnstat/result/day.rb, line 21
def initialize(date, bytes_received, bytes_sent)
  @date = date
  super(bytes_received, bytes_sent)
end

Public Instance Methods

<=>(other) click to toggle source

@return [Integer, nil]

# File lib/vnstat/result/day.rb, line 41
def <=>(other)
  return nil unless other.respond_to?(:bytes_transmitted)
  return nil unless other.respond_to?(:date)

  [date, bytes_transmitted] <=> [other.date, other.bytes_transmitted]
end