Class: Vnstat::Result::Minute
- Inherits:
-
Vnstat::Result
- Object
- Vnstat::Result
- Vnstat::Result::Minute
- Includes:
- DateDelegation, TimeComparable
- Defined in:
- lib/vnstat/result/minute.rb
Overview
A class representing a tracking result for a specific minute.
Instance Attribute Summary collapse
-
#time ⇒ DateTime
readonly
The time the result was captured at.
Attributes inherited from Vnstat::Result
Class Method Summary collapse
-
.extract_from_xml_element(element) ⇒ Minute
Initializes a Minute using the the data contained in the given XML element.
Instance Method Summary collapse
-
#date ⇒ Date
The date the result was captured.
-
#hour ⇒ Integer
The hour the result was captured.
-
#initialize(time, bytes_received, bytes_sent) ⇒ Minute
constructor
Initializes the Minute.
-
#minute ⇒ Integer
The minute the result was captured.
Methods included from TimeComparable
Methods included from DateDelegation
Methods inherited from Vnstat::Result
Constructor Details
#initialize(time, bytes_received, bytes_sent) ⇒ Minute
Initializes the Vnstat::Result::Minute.
22 23 24 25 |
# File 'lib/vnstat/result/minute.rb', line 22 def initialize(time, bytes_received, bytes_sent) @time = time super(bytes_received, bytes_sent) end |
Instance Attribute Details
#time ⇒ DateTime (readonly)
Returns The time the result was captured at.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vnstat/result/minute.rb', line 10 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.min end end |
Class Method Details
.extract_from_xml_element(element) ⇒ Minute
Initializes a Vnstat::Result::Minute using the the data contained in the given XML element.
33 34 35 36 37 38 |
# File 'lib/vnstat/result/minute.rb', line 33 def self.extract_from_xml_element(element) new( Parser.extract_datetime_from_xml_element(element), *Parser.extract_transmitted_bytes_from_xml_element(element) ) end |
Instance Method Details
#date ⇒ Date
The date the result was captured.
44 45 46 |
# File 'lib/vnstat/result/minute.rb', line 44 def date time.to_date end |
#hour ⇒ Integer
The hour the result was captured.
52 53 54 |
# File 'lib/vnstat/result/minute.rb', line 52 def hour time.hour end |
#minute ⇒ Integer
The minute the result was captured.
60 61 62 |
# File 'lib/vnstat/result/minute.rb', line 60 def minute time.min end |