comparison lib/CPT/Parameter/Float.pm @ 1:8691c1c61a8e draft default tip

planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author cpt
date Mon, 05 Jun 2023 02:48:47 +0000
parents
children
comparison
equal deleted inserted replaced
0:54c7a3ea81e2 1:8691c1c61a8e
1 package CPT::Parameter::Float;
2 use Scalar::Util qw(looks_like_number);
3 use Moose;
4 with 'CPT::Parameter';
5
6 has 'min' => ( is => 'rw', isa => 'Num' );
7 has 'max' => ( is => 'rw', isa => 'Num' );
8
9
10 sub galaxy_input {
11 my ( $self, $xml_writer ) = @_;
12 $self->handle_possible_galaxy_input_repeat_start($xml_writer);
13 my %params = $self->get_default_input_parameters('float');
14
15 if(defined $self->min()){
16 $params{min} = $self->min();
17 }
18 if(defined $self->max()){
19 $params{max} = $self->max();
20 }
21
22 $xml_writer->startTag(
23 'param',
24 %params
25 );
26 $xml_writer->endTag('param');
27 $self->handle_possible_galaxy_input_repeat_end($xml_writer);
28 }
29
30
31 sub galaxy_output {
32
33 }
34
35
36 sub validate_individual {
37 my ($self, $value) = @_;
38 if ( looks_like_number( $value ) ) {
39 # Check bounds
40 if ( defined $self->max() && $value > $self->max() ) {
41 push(@{$self->errors()}, sprintf( "Value passed with %s was greater than the allowable upper bound. [%s > %s]", $self->name(), $value, $self->max() ));
42 return 0;
43 }
44 if ( defined $self->min() && $value < $self->min() ) {
45 push(@{$self->errors()}, sprintf( "Value passed with %s was smaller than the allowable minimum bound. [%s < %s]", $self->name(), $value, $self->min() ));
46 return 0;
47 }
48 return 1;
49 }
50 else {
51 push(@{$self->errors()}, sprintf( "Value passed with %s does not look like a float [%s]", $self->name(), $value ));
52 return 0;
53 }
54 }
55
56
57 sub getopt_format {
58 return '=s';
59 }
60
61 no Moose;
62 1;
63
64 __END__
65
66 =pod
67
68 =encoding UTF-8
69
70 =head1 NAME
71
72 CPT::Parameter::Float
73
74 =head1 VERSION
75
76 version 1.99.4
77
78 =head2 galaxy_input
79
80 $file_param->galaxy_input($xml_writer); # where $file_param is a CPT::Parameter::*
81
82 Utilises the $xml_writer to add a <data> block in the <output> section
83
84 =head2 galaxy_output
85
86 $file_param->galaxy_output($xml_writer); # where $file_param is a CPT::Parameter::*
87
88 Utilises the $xml_writer to add a <data> block in the <output> section
89
90 =head2 getopt_format
91
92 Returns the format character for a given CPT::Parameter::* type
93
94 =head1 AUTHOR
95
96 Eric Rasche <rasche.eric@yandex.ru>
97
98 =head1 COPYRIGHT AND LICENSE
99
100 This software is Copyright (c) 2014 by Eric Rasche.
101
102 This is free software, licensed under:
103
104 The GNU General Public License, Version 3, June 2007
105
106 =cut