Sha256: 9f7334b6760c88b8f93bbbd262b1478d7619cc6ee9190f171767ce26230f04e8
Contents?: true
Size: 1.44 KB
Versions: 7
Compression:
Stored size: 1.44 KB
Contents
module Vnstat class Result ## # A class representing a tracking result for a specific minute. # # @attr_reader [DateTime] time The time the result was captured at. class Minute < Result include DateDelegation include TimeComparable attr_reader :time ## # Initializes the {Minute}. # # @param [DateTime] time The time the result was captured at. # @param [Integer] bytes_received The received bytes. # @param [Integer] bytes_sent The sent bytes. def initialize(time, bytes_received, bytes_sent) @time = time super(bytes_received, bytes_sent) end ## # Initializes a {Minute} using the the data contained in the given XML # element. # # @param [Nokogiri::XML::Element] element The XML element. # @return [Minute] def self.extract_from_xml_element(element) new( Parser.extract_datetime_from_xml_element(element), *Parser.extract_transmitted_bytes_from_xml_element(element) ) end ## # The date the result was captured. # # @return [Date] def date time.to_date end ## # The hour the result was captured. # # @return [Integer] def hour time.hour end ## # The minute the result was captured. # # @return [Integer] def minute time.minute end end end end
Version data entries
7 entries across 7 versions & 1 rubygems