| 1 | #============================================================================= | ||||||||||
| 2 | # | ||||||||||
| 3 | # Module: Term::CLI::Argument::Number::Float | ||||||||||
| 4 | # | ||||||||||
| 5 | # Description: Class for floating point arguments in Term::CLI | ||||||||||
| 6 | # | ||||||||||
| 7 | # Author: Steven Bakker (SBAKKER), <sbakker@cpan.org> | ||||||||||
| 8 | # Created: 22/01/18 | ||||||||||
| 9 | # | ||||||||||
| 10 | # Copyright (c) 2018-2022 Steven Bakker | ||||||||||
| 11 | # | ||||||||||
| 12 | # This module is free software; you can redistribute it and/or modify | ||||||||||
| 13 | # it under the same terms as Perl itself. See "perldoc perlartistic." | ||||||||||
| 14 | # | ||||||||||
| 15 | # This software is distributed in the hope that it will be useful, | ||||||||||
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||
| 18 | # | ||||||||||
| 19 | #============================================================================= | ||||||||||
| 20 | |||||||||||
| 21 | package Term::CLI::Argument::Number::Float 0.061000; | ||||||||||
| 22 | |||||||||||
| 23 | 7 | ▶ | use 5.014; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 7 | ▶ | use Scalar::Util 1.23 qw( looks_like_number ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 7 | ▶ | use Moo 1.000001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 7 | ▶ | use namespace::clean 0.25; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 7 | extends 'Term::CLI::Argument::Number'; | |||||||||
| 32 | |||||||||||
| 33 | sub coerce_value { | ||||||||||
| 34 | 10 | ▶ | my ( $self, $arg ) = @_; | ||||||||
|
Subroutine
coerce_value: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 35 | 10 | ▶ | if ( looks_like_number($arg) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 9 | return $arg + 0.0; | |||||||||
| 37 | } | ||||||||||
| 38 | ## no critic (ProhibitExplicitReturnUndef) | ||||||||||
| 39 | 1 | return undef; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 7 | 1; | |||||||||
| 43 | |||||||||||
| 44 | __END__ | ||||||||||
| 45 | |||||||||||
| 46 | =pod | ||||||||||
| 47 | |||||||||||
| 48 | =head1 NAME | ||||||||||
| 49 | |||||||||||
| 50 | Term::CLI::Argument::Number::Float - class for floating point arguments in Term::CLI | ||||||||||
| 51 | |||||||||||
| 52 | =head1 VERSION | ||||||||||
| 53 | |||||||||||
| 54 | version 0.061000 | ||||||||||
| 55 | |||||||||||
| 56 | =head1 SYNOPSIS | ||||||||||
| 57 | |||||||||||
| 58 | use Term::CLI::Argument::Number::Float; | ||||||||||
| 59 | |||||||||||
| 60 | my $arg = Term::CLI::Argument::Number::Float->new( | ||||||||||
| 61 | name => 'index', | ||||||||||
| 62 | min => -1.0, | ||||||||||
| 63 | max => +1.0, | ||||||||||
| 64 | inclusive => 1 | ||||||||||
| 65 | ); | ||||||||||
| 66 | |||||||||||
| 67 | =head1 DESCRIPTION | ||||||||||
| 68 | |||||||||||
| 69 | Class for floating point arguments in L<Term::CLI>(3p). Extends | ||||||||||
| 70 | L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 71 | |||||||||||
| 72 | =head2 Inherits from: | ||||||||||
| 73 | |||||||||||
| 74 | L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 75 | |||||||||||
| 76 | =head2 Consumes: | ||||||||||
| 77 | |||||||||||
| 78 | None. | ||||||||||
| 79 | |||||||||||
| 80 | =head1 CONSTRUCTORS | ||||||||||
| 81 | |||||||||||
| 82 | See L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 83 | |||||||||||
| 84 | =head1 ACCESSORS | ||||||||||
| 85 | |||||||||||
| 86 | See L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 87 | |||||||||||
| 88 | =head1 METHODS | ||||||||||
| 89 | |||||||||||
| 90 | Inherited from | ||||||||||
| 91 | L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 92 | |||||||||||
| 93 | Additionally: | ||||||||||
| 94 | |||||||||||
| 95 | =over | ||||||||||
| 96 | |||||||||||
| 97 | =item B<coerce_value> ( I<VALUE> ) | ||||||||||
| 98 | |||||||||||
| 99 | Overloaded to check for a valid numerical value (using | ||||||||||
| 100 | L<Scalar::Util's looks_like_number|Scalar::Util/looks_like_number>). | ||||||||||
| 101 | |||||||||||
| 102 | =back | ||||||||||
| 103 | |||||||||||
| 104 | =head1 SEE ALSO | ||||||||||
| 105 | |||||||||||
| 106 | L<Scalar::Util>(3p), | ||||||||||
| 107 | L<Term::CLI::Argument::Number::Int>(3p), | ||||||||||
| 108 | L<Term::CLI::Argument::Number>(3p), | ||||||||||
| 109 | L<Term::CLI::Argument>(3p), | ||||||||||
| 110 | L<Term::CLI>(3p). | ||||||||||
| 111 | |||||||||||
| 112 | =head1 AUTHOR | ||||||||||
| 113 | |||||||||||
| 114 | Steven Bakker E<lt>sbakker@cpan.orgE<gt>, 2018. | ||||||||||
| 115 | |||||||||||
| 116 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 117 | |||||||||||
| 118 | Copyright (c) 2018 Steven Bakker | ||||||||||
| 119 | |||||||||||
| 120 | This module is free software; you can redistribute it and/or modify | ||||||||||
| 121 | it under the same terms as Perl itself. See "perldoc perlartistic." | ||||||||||
| 122 | |||||||||||
| 123 | This software is distributed in the hope that it will be useful, | ||||||||||
| 124 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||
| 125 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||
| 126 | |||||||||||
| 127 | =cut | ||||||||||