Class: LogfileInterval::Aggregator::Base

Inherits:
Object
  • Object
show all
Extended by:
Registrar
Includes:
Enumerable
Defined in:
lib/logfile_interval/aggregator/base.rb

Direct Known Subclasses

Appender, Average, Count, Delta, FirstValue, LastValue, NumLines, Sum

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Registrar

aggregator_classes, all, exist?, inherited, klass, register_aggregator

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
# File 'lib/logfile_interval/aggregator/base.rb', line 12

def initialize(options = {})
  @name = options[:name]
  @val = Util::Counter.new
  @size = Util::Counter.new
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/logfile_interval/aggregator/base.rb', line 10

def name
  @name
end

Instance Method Details

#add(value, group_by_value = nil) ⇒ Object

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/logfile_interval/aggregator/base.rb', line 31

def add(value, group_by_value = nil)
  raise NotImplementedError
end

#value(group = nil) ⇒ Object



19
20
21
# File 'lib/logfile_interval/aggregator/base.rb', line 19

def value(group = nil)
  val(key(group))
end

#valuesObject



23
24
25
26
27
28
29
# File 'lib/logfile_interval/aggregator/base.rb', line 23

def values
  if single_value?
    value
  else
    self.inject({}) { |h, v| h[v[0]] = v[1]; h }
  end
end