Acme-FishFarm
view release on metacpan or search on metacpan
lib/Acme/FishFarm/WaterFiltration.pm view on Meta::CPAN
use warnings;
use Carp "croak";
=head1 NAME
Acme::FishFarm::WaterFiltration - Water Filter for Acme::FishFarm
=head1 VERSION
Version 1.01
=cut
our $VERSION = '1.01';
=head1 SYNOPSIS
use 5.010;
use Acme::FishFarm qw( reduce_precision );
use Acme::FishFarm::WaterFiltration;
my $water_filter = Acme::FishFarm::WaterFiltration->install;
say "Water filter installed and switched on!\n";
my $current_reading;
my $waste_count_threshold;
while ( "Fish are living under the water..." ) {
$water_filter->current_waste_count( reduce_precision ( rand(100) ) );
$current_reading = $water_filter->current_waste_count;
$waste_threshold = $water_filter->waste_count_threshold;
print "Current Waste Count: ", $current_reading, " (high: >= ", $waste_threshold, ")\n";
if ( $water_filter->is_cylinder_dirty ) {
print " !! Filtering cylinder is dirty!\n";
print " Cleaned the filter!\n";
$water_filter->clean_cylinder;
} else {
print " Filtering cylinder is still clean.\n";
}
sleep(1);
say "";
}
=head1 EXPORT
None
=head1 DESCRIPTION
This module assumes a cool water filter with a filtering cylinder constantly filtering water in
the tank. It has inlet, outlet and a drainage valves. The drainage valve is only opened when the
cleaners are switched on automatically to remove waste from the cylinder. To be honest, those cleaners look more like spatulas to me :)
This feature is based on the water filter found L<here|https://www.filternox.com/filters/spt-wbv-mr/>
=head1 CREATION SUBROUTINES/METHODS
=head2 install ( %options )
Installs a cool water filtration system.
The following are avaiable for C<%options>:
=over 4
=item current_waste_count
The current waste count in the cylinder. Default is C<0>.
=item waste_threshold
Default value is C<75>.
Sets the waste treshold.
This is the maximum limit of waste in the cylinder. When this count is hit, it will turn on the cleaners / spatulas or whatever it's called :).
=item reduce_waste_count_by
Default is C<10>.
The amount of waste to remove from the cylinder / filter each time the cleaning process is called.
=back
=cut
sub install {
my $class = shift;
my %options = @_;
if ( not $options{current_waste_count} ) {
$options{current_waste_count} = 0;
}
if ( not $options{waste_threshold} ) {
$options{waste_threshold} = 75;
}
$options{is_on_spatulas} = 0;
$options{reduce_waste_count_by} = 10;
bless \%options, "Acme::FishFarm::WaterFiltration";
}
=head1 WASTE LEVEL DETECTING SUBROUTINES/METHODS
=head2 current_waste_count ( $new_waste_count )
Sets / returns the current waste count inside the cylinder.
C<$new_waste_count> is optional. If present, the current waste count will be set to C<$new_waste_count>. Otherwise, returns the current waste count.
( run in 0.689 second using v1.01-cache-2.11-cpan-e1769b4cff6 )