Sha256: 053e50f8845cd791c53e2c6ef548ae12ed91928f0fb297089fac226bccc38c7d
Contents?: true
Size: 582 Bytes
Versions: 323
Compression:
Stored size: 582 Bytes
Contents
package Example; use strict; use warnings; my @com_strings = ('wink', 'double blink', 'close your eyes', 'jump'); sub new { my ($class, $number) = @_; return bless { number => $number }; } sub commands { my $self = shift; return [] if $self->{number} !~ /\d/; my @commands; my @binary = split '' => reverse( substr( sprintf("%b", $self->{number}), -5) ); foreach my $on (0..$#binary) { push @commands => $com_strings[$on] if $binary[$on] and $on < 4; } return [reverse @commands] if $binary[4]; return \@commands; } 1;
Version data entries
323 entries across 323 versions & 1 rubygems