Class: Vnstat::Traffic::Tops
Overview
A class representing a collection of tracked tops.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#[](index) ⇒ Result::Minute
Fetches a single Result::Minute from the collection.
-
#each(&block) ⇒ Object
Iterates over all results in the collection.
- #to_a ⇒ Array<Result::Minute>
Methods inherited from Base
Constructor Details
This class inherits a constructor from Vnstat::Traffic::Base
Instance Method Details
#[](index) ⇒ Result::Minute
Fetches a single Result::Minute from the collection.
27 28 29 |
# File 'lib/vnstat/traffic/tops.rb', line 27 def [](index) to_a[index] end |
#each ⇒ Enumerator #each {|result| ... } ⇒ Tops
Iterates over all results in the collection.
18 19 20 |
# File 'lib/vnstat/traffic/tops.rb', line 18 def each(&block) to_a.each(&block) end |
#to_a ⇒ Array<Result::Minute>
33 34 35 36 37 38 |
# File 'lib/vnstat/traffic/tops.rb', line 33 def to_a elements = traffic_data.xpath('tops/top') elements.map do |element| Result::Minute.extract_from_xml_element(element) end end |