perfdata_for label. Perfdata::Base.to_sym

This commit is contained in:
Denis Knauf 2013-04-09 21:02:17 +02:00
parent 96a58c12dd
commit 27d4db6782

View file

@ -24,6 +24,8 @@ module NSCA
end end
new m new m
end end
def to_sym() label.to_sym end
end end
attr_reader :value attr_reader :value
@ -94,12 +96,19 @@ module NSCA
@perfdatas @perfdatas
end end
def []= perfdata_label, value def perfdata_for label
return push value if value.is_a? PerformanceData::Base if value.is_a? PerformanceData::Base
label
else
perfdata_label = perfdata_label.to_sym perfdata_label = perfdata_label.to_sym
cl = self.class.perfdatas[perfdata_label] cl = self.class.perfdatas[perfdata_label]
cl ||= PerformanceData::Base.new perfdata_label cl || PerformanceData::Base.new( perfdata_label)
@perfdatas[perfdata_label] = cl.new value end
end
def []= perfdata_label, value
return push value if value.is_a? PerformanceData::Base
@perfdatas[perfdata_label] = perfdata_for( perfdata_label).new value
end end
def text def text
@ -109,7 +118,7 @@ module NSCA
end end
def measure perfdata_label, &block def measure perfdata_label, &block
@perfdatas[perfdata_label.to_sym].measure &block push perfdata_for( perfdata_label).measure( &block)
end end
def send() NSCA::send self end def send() NSCA::send self end