Class: DtraceAggregate

Inherits:
Object
  • Object
show all
Defined in:
lib/dtraceaggregate.rb

Overview

Represents an aggregation record built from a series of DtraceAggData records.

Intended to to built up by calling add_record repeatedly with DtraceAggData objects until a completed DtraceAggregate is returned. (until a complete record is available, add_record returns nil).

See dtraceconsumer.rb for an example of this.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDtraceAggregate

Create an empty DtraceAggregate: use add_record to add data.



18
19
20
# File 'lib/dtraceaggregate.rb', line 18

def initialize
  @tuple = Array.new
end

Instance Attribute Details

#tupleObject (readonly)

Returns the value of attribute tuple.



15
16
17
# File 'lib/dtraceaggregate.rb', line 15

def tuple
  @tuple
end

#valueObject (readonly)

Returns the value of attribute value.



15
16
17
# File 'lib/dtraceaggregate.rb', line 15

def value
  @value
end

Instance Method Details

#add_record(r) ⇒ Object

Add a DtraceAggData record to this aggregate. Returns nil until it receives a record of aggtype “last”, when it returns the complete DtraceAggregate.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dtraceaggregate.rb', line 25

def add_record(r)
  case r.aggtype
  when "tuple"
    @tuple << r.value
  when "value"
    @value = r.value
  when "last"
    return self
  end
  nil
end