
Data::Range::Compare::Stream::CallBack - Dynamic compare support plugin

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);

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.

%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] },
);

This section covers the OO Methods in the package.
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
Computes and returns the object that came before this $value. This function uses the helper->{sub_one} code ref to handle the call.
Computes and returns the object that comes after this $value. This function uses the $helper->{add_one} code ref to handle the call.
Returns -1,0,1 similar to <=> or cmp. This function uses the $helper->{cmp_values} code ref to handle the call.
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.

Data::Range::Compare::Stream::Cookbook

Michael Shipper

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 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.