Class: SlashPort::Tuple
- Inherits:
-
Object
- Object
- SlashPort::Tuple
- Defined in:
- app/models/base/tuple.rb
Overview
A tuple is like a slashport row. Each tuple contains a set of labels and data. Each label or data is a key:value pair, allowing you to name each label and each data.
For example, transmit packet counts for a network interface would have a label of ‘interface=eth0’, for example, and a data of ‘txpackets=12345’ Multiple labels are supported/encouraged, as are multiple data. Following the interface example, you could hold all metrics for a single network interface with a single Tuple: ie;
labels: { "interface" => "eth0" }
data: { "txpackets" => 298374, "rxpackets" => 7577, "speed" => 1000 }
Labels are intended to represent attributes that will not change. Data are intended to represent attributes that can change.
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#labels ⇒ Object
Returns the value of attribute labels.
Instance Method Summary collapse
-
#initialize ⇒ Tuple
constructor
A new instance of Tuple.
- #to_json ⇒ Object
Constructor Details
#initialize ⇒ Tuple
Returns a new instance of Tuple.
20 21 22 23 |
# File 'app/models/base/tuple.rb', line 20 def initialize @labels = Hash.new @data = Hash.new end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
19 20 21 |
# File 'app/models/base/tuple.rb', line 19 def data @data end |
#labels ⇒ Object
Returns the value of attribute labels.
18 19 20 |
# File 'app/models/base/tuple.rb', line 18 def labels @labels end |
Instance Method Details
#to_json ⇒ Object
25 26 27 28 29 30 |
# File 'app/models/base/tuple.rb', line 25 def to_json return { "labels" => @labels, "data" => @data, }.to_json end |