class Vnstat::Result
A class representing a tracking result.
@!attribute [r] bytes_received
@return [Integer] The received bytes.
@!attribute [r] bytes_sent
@return [Integer] The sent bytes.
Attributes
bytes_received[R]
bytes_sent[R]
Public Class Methods
extract_from_xml_element(element)
click to toggle source
Initializes a {Result} using the the data contained in the given XML element.
@param [Nokogiri::XML::Element] element The XML element. @return [Result]
# File lib/vnstat/result.rb, line 39 def self.extract_from_xml_element(element) new(*Parser.extract_transmitted_bytes_from_xml_element(element)) end
new(bytes_received, bytes_sent)
click to toggle source
Initializes the {Result}.
@param [Integer] bytes_received
The received bytes. @param [Integer] bytes_sent
The sent bytes.
# File lib/vnstat/result.rb, line 28 def initialize(bytes_received, bytes_sent) @bytes_received = bytes_received @bytes_sent = bytes_sent end
Public Instance Methods
<=>(other)
click to toggle source
@return [Integer, nil]
# File lib/vnstat/result.rb, line 53 def <=>(other) return nil unless other.respond_to?(:bytes_transmitted) bytes_transmitted <=> other.bytes_transmitted end
bytes_transmitted()
click to toggle source
The transmitted bytes (both sent and received).
@return [Integer]
# File lib/vnstat/result.rb, line 47 def bytes_transmitted bytes_received + bytes_sent end