Kit/Choose.pm

filter: Statementstmt 100% 39 / 39 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 75.0% 3 / 4 totaltotal 93.8% 61 / 65 CC 7 SCAR 13.0
CC
7
Cov
94%
BUILD
7.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« Kit/Run.pm ↑ Summary Kit/Widget.pm »
1 package Game::Terminal::Kit::Choose;
2  
3 3 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Game::Terminal::Kit::Picker;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Game::Terminal::Kit::Widget;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = '0.02';
12  
13 has question => (
14 is => 'rw',
15 isa => Str,
16 default => ''
17 3 );
18  
19 has [qw/choices legend/] => (
20 is => 'rw',
21 isa => ArrayRef
22 3 );
23  
24 has [qw/at log screen picker/] => (
25 is => 'rw'
26 3 );
27  
28 9 ▶sub BUILD {
Subroutine BUILD: called CC=7 SCAR=19.7
Pod undocumented
29 9 my ($self) = @_;
30 9 ▶ $self->question('') unless defined $self->question;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->question 0 9 9
31 9 ▶ $self->choices([]) unless $self->choices;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->choices 0 9 9
32 9 ▶ $self->legend([ '', 'up and down to choose, enter to take it, q to leave' ])
Branch: 1 branch
BranchTrueFalseTotal
unless $self->legend 7 2 9
33 unless $self->legend;
34 $self->picker(Game::Terminal::Kit::Picker->new(
35 9 ▶ items => [ map { { value => $_->[0], label => $_->[1], about => $_->[2] } } @{$self->choices} ],
Branch: 3 branches
BranchTrueFalseTotal
defined $self->at ? : 1 8 9
$self->log ? : 1 8 9
$self->screen ? : 0 9 9
36 head => [ $self->question, '' ],
37 legend => $self->legend,
38 window => 0,
39 (defined $self->at ? (at => $self->at) : ()),
40 ($self->log ? (log => $self->log) : ()),
41 ($self->screen ? (screen => $self->screen) : ()),
42 ));
43 9 $self->at($self->picker->at);
44 9 return $self;
45 }
46  
47 30 ▶sub lines {
Subroutine lines: called CC=1 SCAR=0.0
Pod documented
48 30 my ($self) = @_;
49 30 return $self->picker->lines;
50 }
51  
52 33 ▶sub step {
Subroutine step: called CC=1 SCAR=0.0
Pod documented
53 33 my ($self, $key) = @_;
54 33 my @result = $self->picker->step($key);
55 33 $self->at($self->picker->at);
56 33 return @result;
57 }
58  
59 3 ▶sub run {
Subroutine run: called CC=1 SCAR=0.0
Pod documented
60 3 my ($self, $keys, $screen) = @_;
61 3 return Game::Terminal::Kit::Widget::run($self, $keys, $screen);
62 }
63  
64 3 1;
65  
66 __END__
« Kit/Run.pm ↑ Summary Kit/Widget.pm »