NAME
Data::Range::Compare::Stream::CallBack - Dynamic compare support plugin
SYNOPSIS
use Data::Range::Compare::Stream::CallBack qw(%HELPER);
# create the factory instance we will hand around
my $factory_instance=new Data::Range::Compare::Stream::CallBack(\%HELPER);
DESCRIPTION
This module module provides a dynamic method of supporting diffrent data types without the need to subclass Data::Range::Compare::Stream. Note: this class does in fact subclass Data::Range::Compare::Stream.
Exports
%HELPER is exported by default.
%HELPER is a hash that contains 3 anonymous functions.
our %HELPER=(
sub_one=>sub { $_[0] - 1 },
add_one=>sub { $_[0] + 1 },
cmp_values=>sub { $_[0] <=> $_[1] },
);
OO Methods
This section covers the OO Methods in the package.
my $range=new Data::Range::Compare::Stream::CallBack(\%HELPER,$range_start,$range_end);
my $range=new Data::Range::Compare::Stream::CallBack(\%HELPER$range_start,$range_end,$data);
my $factory_instance=new Data::Range::Compare::Stream::CallBack(\%HELPER);
Object constructor: Creates a new instance of Data::Range::Compare::Stream.
Arguments an their meanings:
\%HELPER -- Required. This hash ref use used to handle comparison, addition and subtraction $range_start -- Required Represents the start of this given range $range_end -- Required Represents the end of this range. $data -- Optional Used to tag this range with your data
my $new_value=$range->sub_one($value);
Computes and returns the object that came before this $value. This function uses the helper->{sub_one} code ref to handle the call.
my $new_value=$range->add_one($value)
Computes and returns the object that comes after this $value. This function uses the $helper->{add_one} code ref to handle the call.
my $cmp=$range->cmp_values($value_a,$value_b)
Returns -1,0,1 similar to <=> or cmp. This function uses the $helper->{cmp_values} code ref to handle the call.
my $range=$factory_instance->factory(0,1);
my $range=$factory_instance->factory(0,1,$data);
Given an instance of Data::Range::Compare::Stream::CallBack, this function is used to create a new range object that will also contain the related %HELPER function.
SEE ALSO
Data::Range::Compare::Stream::Cookbook
AUTHOR
Michael Shipper
Source-Forge Project
As of version 0.001 the Project has been moved to Source-Forge.net
Data Range Compare https://sourceforge.net/projects/data-range-comp/
COPYRIGHT
Copyright 2011 Michael Shipper. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.