line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Search::QS::Options::Int; |
2
|
|
|
|
|
|
|
$Search::QS::Options::Int::VERSION = '0.04'; |
3
|
4
|
|
|
4
|
|
1687
|
use Moose; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
19
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: An integer object with a few methods |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has name => ( is => 'ro', isa => 'Str'); |
9
|
|
|
|
|
|
|
has value => ( is => 'rw', isa => 'Int|Undef', builder => '_build_value'); |
10
|
|
|
|
|
|
|
has default => ( is => 'ro', isa => 'Int|Undef', default => undef); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub to_qs() { |
14
|
14
|
|
|
14
|
1
|
25
|
my $s = shift; |
15
|
14
|
|
50
|
|
|
23
|
my $amp = shift || 0; |
16
|
14
|
100
|
|
|
|
336
|
return '' if ($s->value ~~ $s->default); |
17
|
9
|
50
|
|
|
|
190
|
return $s->name . '=' . $s->value . ($amp ? '&' : ''); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub reset() { |
21
|
12
|
|
|
12
|
1
|
17
|
my $s = shift; |
22
|
12
|
|
|
|
|
252
|
$s->value($s->default); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build_value() { |
26
|
18
|
|
|
18
|
|
443
|
return shift->default; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
4
|
|
21669
|
no Moose; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
17
|
|
30
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=pod |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=encoding UTF-8 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Search::QS::Options::Int - An integer object with a few methods |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 VERSION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
version 0.04 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
An abstract class to incapsulate Undef|Int value |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 name() |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Defined in subclass, is the name of the integer value |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 value() |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
The value of the integer |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 default() |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Defined in subclass, the default value of the integer |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 to_qs($append_ampersand) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Return a query string of the internal rappresentation of the object. If L<value()> |
69
|
|
|
|
|
|
|
is different by L<default()> and $append_ampersand is true, it appends |
70
|
|
|
|
|
|
|
an ampersand (&) at the end of the returned string |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 reset() |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Reset the object to the L<default()> value. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Emiliano Bruni <info@ebruni.it> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This software is copyright (c) 2019 by Emiliano Bruni. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
85
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |