File Coverage

blib/lib/Eliza/Chatbot/Option.pm
Criterion Covered Total %
statement 16 20 80.0
branch 1 2 50.0
condition n/a
subroutine 5 6 83.3
pod 2 2 100.0
total 24 30 80.0


line stmt bran cond sub pod time code
1             package Eliza::Chatbot::Option;
2              
3 10     10   16842 use Moo;
  10         11785  
  10         51  
4 10     10   3939 use MooX::LazierAttributes;
  10         2607  
  10         46  
5 10     10   5790 use Eliza::Chatbot::ScriptParser;
  10         28  
  10         2216  
6              
7             attributes (
8             [qw/script_file debug_text transform_text botprompt userprompt/] => [ rw, '', {lzy}],
9             [qw/prompts_on memory_on likelihood_of_using_memory/] => [ rw, 1, {lzy}],
10             name => [ rw, 'Eliza', {lzy}],
11             debug => [rw, 0, {lzy}],
12             max_memory_size => [rw, 5, {lzy}],
13             memory => [rw, [ ], {lzy}],
14             data => [ro, nan, {lzy, bld}]
15             );
16              
17             sub _build_data {
18 23     23   23271 my $self = shift;
19 23         438 my $parser = Eliza::Chatbot::ScriptParser->new(script_file => $self->script_file);
20 23         8565 $parser->parse_script_data;
21 23         557 return $parser;
22             }
23              
24             sub myrand {
25 11     11 1 95 my ($self, $max) = @_;
26 11 50       23 my $n = defined $max ? $max : 1;
27 11         3910 return rand($n);
28             }
29              
30             sub welcome_message {
31 0     0 1   my $self = shift;
32 0           my $initial = $self->data->initial;
33 0           return $initial->[ $self->myrand( scalar @{$initial} ) ];
  0            
34             }
35              
36             1;
37              
38             __END__