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.119 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.118 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.117 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.116 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.115 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.114 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.113 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.111 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.110 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.109 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.108 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.107 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm
trackler-2.2.1.106 tracks/perl5/exercises/robot-name/.meta/solutions/RobotName.pm