From c6cbf050974c8f6642fa1d7bde309710b66cbfa0 Mon Sep 17 00:00:00 2001 From: Gavin Carr Date: Fri, 16 Mar 2007 11:25:15 +0000 Subject: Cleanups, mostly to N::P::Range/Threshold/Performance. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1641 f882894a-f735-0410-b71e-b25c423dba1c --- lib/Nagios/Plugin/Range.pm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'lib/Nagios/Plugin/Range.pm') diff --git a/lib/Nagios/Plugin/Range.pm b/lib/Nagios/Plugin/Range.pm index dbb637c..3828d1a 100644 --- a/lib/Nagios/Plugin/Range.pm +++ b/lib/Nagios/Plugin/Range.pm @@ -4,7 +4,12 @@ use 5.006; use strict; use warnings; + use Carp; +use base qw(Class::Accessor::Fast); +__PACKAGE__->mk_accessors( + qw(start end start_infinity end_infinity alert_on) +); use Nagios::Plugin::Functions; our ($VERSION) = $Nagios::Plugin::Functions::VERSION; @@ -12,15 +17,7 @@ our ($VERSION) = $Nagios::Plugin::Functions::VERSION; use overload '""' => sub { shift->_stringify }; -use Class::Struct; -struct "Nagios::Plugin::Range" => { - start => '$', - end => '$', - start_infinity => '$', # TRUE / FALSE - end_infinity => '$', # TRUE / FALSE - alert_on => '$', # OUTSIDE 0, INSIDE 1, not defined == range not set - }; - +# alert_on constants (undef == range not set) use constant OUTSIDE => 0; use constant INSIDE => 1; @@ -119,7 +116,14 @@ sub check_range { } } +# Constructor - map args to hashref for SUPER +sub new +{ + shift->SUPER::new({ @_ }); +} + 1; + __END__ =head1 NAME @@ -135,7 +139,7 @@ Nagios::Plugin::Range - class for handling Nagios::Plugin range data. $r = Nagios::Plugin::Range->new; # Instantiate by parsing a standard nagios range string - $r = Nagios::Plugin::Range->parse_range_string; + $r = Nagios::Plugin::Range->parse_range_string( $range_str ); # Returns true if the range is defined/non-empty $r->is_set; -- cgit v1.2.3-74-g34f1