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.180 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.179 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.178 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.177 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.176 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.175 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.174 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.173 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.172 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.171 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.170 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.169 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.167 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.166 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.165 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.164 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.163 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.162 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.161 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.160 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm