Sha256: 4611e7e3c9ef567b948ba062b629a7dc6cd7f093faa0050fb23b365a17a93507

Contents?: true

Size: 493 Bytes

Versions: 73

Compression:

Stored size: 493 Bytes

Contents

package RobotName;
use warnings;
use strict;

sub new {
    my $class = shift;
    return bless {}, $class;
}

sub name {
    my $self = shift;
    return exists $self->{name} ? $self->{name} : $self->reset_name();
}

sub reset_name {
    my $self = shift;
    $self->{name} = _rand_letter() . _rand_letter() . _suffix();
    return $self->{name};
}

sub _rand_letter {
    my @letters = 'A'..'Z';
    return $letters[int rand $#letters];
}

sub _suffix {
    return 100 + int rand 900;
}

1;

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.138 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.137 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.136 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.135 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.134 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.133 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.132 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.131 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.130 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.129 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.128 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.127 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.126 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.125 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.124 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.123 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.122 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.121 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.120 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm