class Vnstat::Result::Month
A class representing a tracking result for a specific month.
@!attribute [r] year
@return [Integer] The year the result was captured in.
@!attribute [r] month
@return [Integer] The month the result was captured in.
Attributes
month[R]
year[R]
Public Class Methods
extract_from_xml_element(element)
click to toggle source
Initializes a {Month} using the the data contained in the given XML element.
@param [Nokogiri::XML::Element] element The XML element. @return [Month]
# File lib/vnstat/result/month.rb, line 34 def self.extract_from_xml_element(element) new( *Parser.extract_month_from_xml_element(element), *Parser.extract_transmitted_bytes_from_xml_element(element) ) end
new(year, month, bytes_received, bytes_sent)
click to toggle source
Initializes the {Month}.
@param [Integer] year The year the result was captured in. @param [Integer] month The month the result was captured in. @param [Integer] bytes_received The received bytes. @param [Integer] bytes_sent The sent bytes.
Calls superclass method
Vnstat::Result::new
# File lib/vnstat/result/month.rb, line 22 def initialize(year, month, bytes_received, bytes_sent) @year = year @month = month super(bytes_received, bytes_sent) end
Public Instance Methods
<=>(other)
click to toggle source
@return [Integer, nil]
# File lib/vnstat/result/month.rb, line 43 def <=>(other) return nil unless other.respond_to?(:bytes_transmitted) return nil if !other.respond_to?(:year) || !other.respond_to?(:month) [year, month, bytes_transmitted] <=> [other.year, other.month, other.bytes_transmitted] end