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