Class: NewrelicSphinx::Metric

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, name, units, mode = :plain) ⇒ Metric

Returns a new instance of Metric.



11
12
13
14
15
# File 'lib/newrelic_sphinx/agent.rb', line 11

def initialize(key, name, units, mode = :plain)
  @key, @name, @units, @mode = key, name, units, mode
  @value = 0
  @last_value = 0
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/newrelic_sphinx/agent.rb', line 8

def key
  @key
end

#last_valueObject (readonly)

Returns the value of attribute last_value.



8
9
10
# File 'lib/newrelic_sphinx/agent.rb', line 8

def last_value
  @last_value
end

#modeObject (readonly)

Returns the value of attribute mode.



8
9
10
# File 'lib/newrelic_sphinx/agent.rb', line 8

def mode
  @mode
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/newrelic_sphinx/agent.rb', line 8

def name
  @name
end

#unitsObject (readonly)

Returns the value of attribute units.



8
9
10
# File 'lib/newrelic_sphinx/agent.rb', line 8

def units
  @units
end

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/newrelic_sphinx/agent.rb', line 9

def value
  @value
end

Instance Method Details

#incremental?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/newrelic_sphinx/agent.rb', line 25

def incremental?
  mode == :incremental
end

#memorizeObject



17
18
19
# File 'lib/newrelic_sphinx/agent.rb', line 17

def memorize
  @last_value = value
end

#plain?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/newrelic_sphinx/agent.rb', line 21

def plain?
  mode == :plain
end