| 1 | package Weaving::Tablet; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Weaving::Tablet::Card; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | our $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use version; $VERSION = qv('0.9.4'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | has 'pattern_length' => (isa => 'Int', is => 'ro', default => 10); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | has 'number_of_holes' => (isa => 'Int', is => 'ro', default => 4, writer => '_set_number_of_holes'); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | has 'number_of_cards' => (isa => 'Int', is => 'rw', default => 20); | |||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | has 'cards' => (isa => 'ArrayRef[Weaving::Tablet::Card]', is => 'ro', default => sub { [] }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | has 'color_table' => (isa => 'ArrayRef[Str]', is => 'ro', default => sub { [qw/red green blue black yellow white/] }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | has 'file_name' => (isa => 'Str', is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | has 'dirty' => (isa => 'Bool', is => 'rw', default => 0); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | has 'is_twill' => ( isa => 'Bool', is => 'rw', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | sub BUILD | ||||||||||||||||||||||||||||||||||||||||||
| 22 | { | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | if (defined $self->file_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $self->load_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 40 | push @{$self->cards}, Weaving::Tablet::Card->new(number_of_turns => | |||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | $self->pattern_length) for 1..$self->number_of_cards; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | sub load_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_pattern: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return 0 unless defined $self->file_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return 0 unless -r $self->file_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | open my $pattern, '<', $self->file_name or croak "Can't open ".$self->file_name.": $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my ($cards, $rows, $holes) = (split(/ /,<$pattern>))[0,2,4]; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $holes ||= 4; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$holes ||= 4
MC/DC0%0/1
$holes ||= 4
$holes
Truth table0%0/2
A
A= $holes
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $self->number_of_cards($cards); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $self->_set_number_of_holes($holes); | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # prime cards with empty cards | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | push @{$self->cards}, Weaving::Tablet::Card->new(number_of_turns => 0) for 1..$self->number_of_cards; | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $card; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | while (<$pattern>) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | last unless /^[\\\/|]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->insert_pick([-1, $_]); | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # now $_ contains the start line... | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | tr /ABCDEFGH/01234567/; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my @starts = split(//, $_); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | for my $card (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $self->cards->[$card]->start($starts[$card]); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $_ = <$pattern>; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my @SZ = split(//, $_); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | for my $card (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->cards->[$card]->SZ($SZ[$card]); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | for my $card (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $_ = <$pattern>; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->cards->[$card]->set_threading([split(/,/, $_)]); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | pop @{$self->color_table} while @{$self->color_table}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | while (<$pattern>) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | push @{$self->color_table}, $_;# use X color names here | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | close $pattern; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->color_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->twist_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->dirty(0); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | sub reload_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload_pattern: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->delete_card(0 .. $self->number_of_cards-1); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $self->load_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | sub save_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save_pattern: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $file = $self->{file_name}; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return 0 unless $file || -w $file || -w '.'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$file or -w $file or -w "."
$file or -w $file
MC/DC0%0/3
$file or -w $file or -w "."
$file
-w $file
-w "."
Truth table0%0/4
A or B or C
A= $fileB= -w $fileC= -w "."
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->color_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | open my $pattern, ">", $file or return 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | print $pattern $self->dump_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | close $pattern; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $self->dirty(0); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | sub dump_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_pattern: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my ($row, $card); | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $pattern; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $pattern = join(" ",$self->number_of_cards, 'cards', $self->number_of_rows, 'rows', $self->number_of_holes, 'holes')."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | for my $row (reverse 0 .. $self->number_of_rows-1) | |||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $pattern .= join('', $self->row_turns($row), "\n"); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | (my $start = join("",@{$self->start})) =~ tr/01234567/ABCDEFGH/; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $pattern .= $start."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $pattern .= join("",@{$self->SZ})."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | for my $card (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $pattern .= join(",",@{$self->threading($card)})."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | foreach (@{$self->color_table}) | |||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $pattern .= $_."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $pattern; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | sub color_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color_pattern: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | my @cardlist = @_ == 0 ? (0 .. $self->number_of_cards-1) : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | for my $card (@cardlist) | |||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $self->cards->[$card]->color_card; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | sub twist_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
twist_pattern: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | my @cardlist = @_ == 0 ? (0 .. $self->number_of_cards-1) : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | for my $card (@cardlist) | |||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 20 | $self->cards->[$card]->twist_card; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | sub float_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 172 | { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
float_pattern: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | my @cardlist = @_ == 0 ? (0 .. $self->number_of_cards-1) : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | for my $card (@cardlist) | |||||||||||||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $self->cards->[$card]->float_card; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | sub print_twist | ||||||||||||||||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my ($self, @rowlist) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_twist: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $self->twist_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | @rowlist = ($self->number_of_rows-1) unless @rowlist; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if (wantarray) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | { | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my @twist; | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | foreach my $row (@rowlist) | |||||||||||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | push @twist, [$self->row_twist($row)]; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return @twist; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | else | ||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $s; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | foreach my $row (@rowlist) | |||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $rp = $row+1; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $s .= "twist for row $rp: "; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $s .= join(",", $self->row_twist($row)); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $s .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | sub insert_pick | ||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_pick: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | ▶ | push @_, [$self->number_of_rows-1, '/'x$self->number_of_cards] if @_ == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | ▶ | while (@_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | my $rowspec = shift; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | my ($after, $turns) = @$rowspec; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | $turns = pack('A'.$self->number_of_cards, $turns.'/' x $self->number_of_cards); | |||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | my @turns = split(//, $turns); | |||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | for my $card (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 40 | $self->cards->[$card]->insert_picks($after, $turns[$card]); | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | sub insert_card | ||||||||||||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_card: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | while (@_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $rowspec = shift; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my ($after, $turns) = @$rowspec; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $turns = pack('A'.$self->{number_of_rows}, $turns.'/' x $self->{number_of_rows}); | |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $card = Weaving::Tablet::Card->new(turns => $turns); | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | splice @{$self->cards}, $after+1, 0, $card; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | sub delete_row | ||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_row: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my @rows = reverse sort { $a <=> $b } @_; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | foreach my $card (0..$self->{number_of_cards}-1) | |||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $self->cards->[$card]->delete_picks(@rows); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | sub delete_card | ||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_card: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | foreach my $card (reverse sort @_) | |||||||||||||||||||||||||||||||||||||||||
| 260 | { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->{number_of_cards}--; | |||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | splice @{$self->cards}, $card, 1; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | sub duplicate_row | ||||||||||||||||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
duplicate_row: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | DUP: while (1) | |||||||||||||||||||||||||||||||||||||||||
| 272 | { | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | my $from = shift; return unless defined $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | my $to = shift; $to = $self->{number_of_rows}-1 unless defined $to; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $self->{number_of_rows}++; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | foreach my $card (0..$self->{number_of_cards}-1) | |||||||||||||||||||||||||||||||||||||||||
| 279 | { | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | splice @{$self->{turns}[$card]}, $to, 0, $self->{turns}[$card][$from]; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | last DUP unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | sub duplicate_card | ||||||||||||||||||||||||||||||||||||||||||
| 289 | { | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
duplicate_card: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | DUP: while (1) | |||||||||||||||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $from = shift; return unless defined $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | my $to = shift; $to = $self->{number_of_cards}-1 unless defined $to; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $self->{number_of_cards}++; | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | splice @{$self->{turns}}, $to, 0, [@{$self->{turns}[$from]}]; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | splice @{$self->{SZ}}, $to, 0, $self->{SZ}[$from]; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | splice @{$self->{start}}, $to, 0, $self->{start}[$from]; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | splice @{$self->{threading}}, $to, 0, [@{$self->{threading}[$from]}]; | |||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | last DUP unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | sub number_of_rows | ||||||||||||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | ▶ | shift->cards->[0]->{number_of_turns}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
number_of_rows: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | sub SZ | ||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SZ: called CC=16 SCAR=48.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | my $card = shift; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | ▶ | if (defined $value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | warn "attempt to use $value as SZ setting for card $card" unless $value =~ /[SZ]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | return unless $value =~ /[SZ]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $self->cards->[$card]->SZ($value); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | ▶ | elsif (defined($card) and ref($card) eq 'ARRAY') | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $card and ref $card eq "ARRAY"
MC/DC0%0/2
defined $card and ref $card eq "ARRAY"
defined $card
ref $card eq "ARRAY"
Truth table33%1/3
A and B
A= defined $cardB= ref $card eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if (grep !/^[SZ]$/, @$card) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | { | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | warn "attempt to use invalid SZ value for card $card"; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | croak; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my @values = @$card; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | pop @values while @values > $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | splice @{$self->{SZ}}, 0, @values, @values; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | ▶ | elsif (defined($card) and not ref($card)) | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $card and not ref $card
MC/DC0%0/2
defined $card and not ref $card
defined $card
not ref $card
Truth table33%1/3
A and not(B)
A= defined $cardB= not ref $card
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | { | ||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | return $self->cards->[$card]->SZ; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | elsif (not defined $card) | ||||||||||||||||||||||||||||||||||||||||||
| 350 | { | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | my @SZ; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | for my $card (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 353 | { | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 20 | push @SZ, $self->cards->[$card]->SZ; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | return \@SZ; | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | else | ||||||||||||||||||||||||||||||||||||||||||
| 359 | { | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | sub start | ||||||||||||||||||||||||||||||||||||||||||
| 365 | { | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $card = shift; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if (defined $value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | warn "attempt to use $value as start setting for card $card" unless $value =~ /[01234567]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | return unless $value =~ /[01234567]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->cards->[$card]->start($value); | |||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | ▶ | elsif (defined($card) and ref($card) eq 'ARRAY') | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $card and ref $card eq "ARRAY"
MC/DC0%0/2
defined $card and ref $card eq "ARRAY"
defined $card
ref $card eq "ARRAY"
Truth table0%0/3
A and B
A= defined $cardB= ref $card eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | { | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | if (grep !/^[01234567]$/, @$card) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | { | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | warn "attempt to use invalid start value for card $card"; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | for my $c (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 388 | { | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | $self->start($c, $card->[$c]); | |||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | ▶ | elsif (defined($card) and not ref($card)) | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $card and not ref $card
MC/DC0%0/2
defined $card and not ref $card
defined $card
not ref $card
Truth table0%0/3
A and not(B)
A= defined $cardB= not ref $card
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | { | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | return $self->cards->[$card]->start; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | elsif (not defined $card) | ||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my @start; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | for my $card (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 404 | { | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | push @start, $self->cards->[$card]->start; | |||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | return \@start; | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | else | ||||||||||||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | sub threading | ||||||||||||||||||||||||||||||||||||||||||
| 416 | { | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
threading: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my ($card, $hole, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if (@_ == 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | { | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | return [map { $self->cards->[$_]->threading } (0 .. $self->number_of_cards)]; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | elsif (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||||
| 425 | { | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | return $self->cards->[$card]->threading; | |||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | elsif (@_ == 2) # (card, hole) or (card, listref_of_color_indices) | ||||||||||||||||||||||||||||||||||||||||||
| 431 | { | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | unless (ref($hole)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | { | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | return if $hole < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | return if $hole >= $self->number_of_holes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return ($self->cards->[$card]->threading->[$hole]); | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | elsif (ref($hole) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||
| 441 | { | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | return if grep /\D/, @$hole; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | return if @$hole != $self->number_of_holes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $self->card->[$card]->set_threading($hole); | |||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | else | ||||||||||||||||||||||||||||||||||||||||||
| 450 | { | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||
| 454 | elsif (@_ >= 3) | ||||||||||||||||||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | return if $hole < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | return if $hole >= $self->number_of_holes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $self->cards->[$card]->threading->[$hole] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | sub turns | ||||||||||||||||||||||||||||||||||||||||||
| 466 | { | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
turns: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | my ($card, $row, $turn) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | if (@_ >= 3) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | { | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | return if $row < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | return if $row >= $self->number_of_rows; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | return unless $turn =~ /^[\\\/|]$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | $self->card_turns($card)->[$row] = $turn; | |||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 481 | { | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | return if $row < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | return if $row >= $self->number_of_rows; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | return $self->card_turns($card)->[$row]; | |||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | else | ||||||||||||||||||||||||||||||||||||||||||
| 489 | { | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return (@{$self->{turns}}); | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | sub row_turns | ||||||||||||||||||||||||||||||||||||||||||
| 495 | { | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_turns: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my ($row, $turns) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if (@_ >= 2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | { | ||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | return if $row < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | return if $row >= $self->number_of_rows; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | foreach my $c (0..$self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 504 | { | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | last if $c >= @$turns; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $self->card_turns($c)->[$row] = $$turns[$c]; | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | elsif (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||||
| 511 | { | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | return if $row < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | return if $row >= $self->number_of_rows; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my @row; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | foreach my $c (0..$self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 516 | { | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | push @row, $self->card_turns($c)->[$row]; | |||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | return @row; | |||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 521 | else | ||||||||||||||||||||||||||||||||||||||||||
| 522 | { | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | sub card_turns | ||||||||||||||||||||||||||||||||||||||||||
| 528 | { | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_turns: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my ($card, $turns) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | if (@_ >= 2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my @values = @$turns; | |||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | pop @values while @values > $self->number_of_rows; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $self->dirty(1); | |||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | splice @{$self->cards->[$card]->turns}, 0, @values, @values; | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | elsif (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | return if $card < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | return if $card >= $self->number_of_cards; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | return $self->cards->[$card]->turns; | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | else | ||||||||||||||||||||||||||||||||||||||||||
| 548 | { | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | sub twist | ||||||||||||||||||||||||||||||||||||||||||
| 554 | { | ||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
twist: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my ($card, $row) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | return @{$self->{twist}} unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | return unless ($card >= 0 and $card < $self->number_of_cards); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$card >= 0 and $card < $self->number_of_cards
MC/DC0%0/2
$card >= 0 and $card < $self->number_of_cards
$card >= 0
$card < $self->number_of_cards
Truth table0%0/3
A and B
A= $card >= 0B= $card < $self->number_of_cards
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | return unless ($row >= 0 and $row < $self->number_of_rows); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$row >= 0 and $row < $self->number_of_rows
MC/DC0%0/2
$row >= 0 and $row < $self->number_of_rows
$row >= 0
$row < $self->number_of_rows
Truth table0%0/3
A and B
A= $row >= 0B= $row < $self->number_of_rows
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | return $self->card_twist->[$row]; | |||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||
| 564 | sub row_twist | ||||||||||||||||||||||||||||||||||||||||||
| 565 | { | ||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_twist: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $row = shift; | |||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | return unless defined $row; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | return unless ($row >= 0 and $row < $self->number_of_rows); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$row >= 0 and $row < $self->number_of_rows
MC/DC0%0/2
$row >= 0 and $row < $self->number_of_rows
$row >= 0
$row < $self->number_of_rows
Truth table0%0/3
A and B
A= $row >= 0B= $row < $self->number_of_rows
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my @row; | |||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | foreach my $c (0 .. $self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 573 | { | ||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | push @row, $self->card_twist($c)->[$row]; | |||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | return @row; | |||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | sub card_twist | ||||||||||||||||||||||||||||||||||||||||||
| 580 | { | ||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_twist: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my $card = shift; | |||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | return unless defined $card; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | return unless ($card >= 0 and $card < $self->number_of_cards); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$card >= 0 and $card < $self->number_of_cards
MC/DC0%0/2
$card >= 0 and $card < $self->number_of_cards
$card >= 0
$card < $self->number_of_cards
Truth table0%0/3
A and B
A= $card >= 0B= $card < $self->number_of_cards
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | return @{$self->cards->[$card]->twist}; | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | sub color | ||||||||||||||||||||||||||||||||||||||||||
| 590 | { | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my ($card, $row) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | return @{$self->{color}} unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | return unless ($card >= 0 and $card < $self->number_of_cards); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$card >= 0 and $card < $self->number_of_cards
MC/DC0%0/2
$card >= 0 and $card < $self->number_of_cards
$card >= 0
$card < $self->number_of_cards
Truth table0%0/3
A and B
A= $card >= 0B= $card < $self->number_of_cards
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | return unless ($row >= 0 and $row < $self->number_of_rows); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$row >= 0 and $row < $self->number_of_rows
MC/DC0%0/2
$row >= 0 and $row < $self->number_of_rows
$row >= 0
$row < $self->number_of_rows
Truth table0%0/3
A and B
A= $row >= 0B= $row < $self->number_of_rows
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | return $self->card_color($card)->[$row]; | |||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | sub row_color | ||||||||||||||||||||||||||||||||||||||||||
| 601 | { | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_color: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $row = shift; | |||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | return unless defined $row; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | return unless ($row >= 0 and $row < $self->number_of_rows); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$row >= 0 and $row < $self->number_of_rows
MC/DC0%0/2
$row >= 0 and $row < $self->number_of_rows
$row >= 0
$row < $self->number_of_rows
Truth table0%0/3
A and B
A= $row >= 0B= $row < $self->number_of_rows
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | my @row; | |||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | foreach my $c (0..$self->number_of_cards-1) | |||||||||||||||||||||||||||||||||||||||||
| 609 | { | ||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | push @row, $self->card_color($c)->[$row]; | |||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | return @row; | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | sub card_color | ||||||||||||||||||||||||||||||||||||||||||
| 616 | { | ||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_color: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my $card = shift; | |||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | return unless defined $card; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | return unless ($card >= 0 and $card < $self->number_of_cards); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$card >= 0 and $card < $self->number_of_cards
MC/DC0%0/2
$card >= 0 and $card < $self->number_of_cards
$card >= 0
$card < $self->number_of_cards
Truth table0%0/3
A and B
A= $card >= 0B= $card < $self->number_of_cards
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | return $self->cards->[$card]->color; | |||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | 3 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||||||||||||||||
| 627 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | Weaving::Tablet - Perl extension for manipulating tablet weaving patterns | ||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | This document describes Weaving::Tablet version 0.9.0 | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | use Weaving::Tablet; | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | my $old_pattern = Weaving::Tablet::new_from_file("my_pattern"); | ||||||||||||||||||||||||||||||||||||||||||
| 644 | my $new_pattern = Weaving::Tablet::new_from_scratch(20, 40); # 20 cards, 40 rows | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | $pattern->load_pattern; # load pattern from $pattern->{file_name} | ||||||||||||||||||||||||||||||||||||||||||
| 647 | $pattern->save_pattern; # write pattern to $pattern->{file_name} | ||||||||||||||||||||||||||||||||||||||||||
| 648 | $pattern->color_pattern; # compute $pattern->{color} | ||||||||||||||||||||||||||||||||||||||||||
| 649 | $pattern->twist_pattern; # compute $pattern->{twist} | ||||||||||||||||||||||||||||||||||||||||||
| 650 | $pattern->print_twist; # print accumulated twist for pattern | ||||||||||||||||||||||||||||||||||||||||||
| 651 | $pattern->print_twist(10); # print accumulated twist at row 10 | ||||||||||||||||||||||||||||||||||||||||||
| 652 | $pattern->print_twist(10,20,25); # print accumulated twist at rows 10,20,25 | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | $pattern->insert_pick; | ||||||||||||||||||||||||||||||||||||||||||
| 655 | $pattern->insert_card; | ||||||||||||||||||||||||||||||||||||||||||
| 656 | $pattern->delete_row; | ||||||||||||||||||||||||||||||||||||||||||
| 657 | $pattern->delete_card; | ||||||||||||||||||||||||||||||||||||||||||
| 658 | $pattern->duplicate_row; | ||||||||||||||||||||||||||||||||||||||||||
| 659 | $pattern->duplicate_card; | ||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | # member functions | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | # data retrieval | ||||||||||||||||||||||||||||||||||||||||||
| 664 | $pattern->file_name | ||||||||||||||||||||||||||||||||||||||||||
| 665 | $pattern->number_of_cards | ||||||||||||||||||||||||||||||||||||||||||
| 666 | $pattern->number_of_rows | ||||||||||||||||||||||||||||||||||||||||||
| 667 | $pattern->number_of_holes | ||||||||||||||||||||||||||||||||||||||||||
| 668 | $pattern->SZ, $pattern->SZ(card) | ||||||||||||||||||||||||||||||||||||||||||
| 669 | $pattern->threading, $pattern->threading(card), $pattern->threading(card,hole) | ||||||||||||||||||||||||||||||||||||||||||
| 670 | $pattern->start, $pattern->start(card) | ||||||||||||||||||||||||||||||||||||||||||
| 671 | $pattern->color_table, $pattern->color_table(color_index) | ||||||||||||||||||||||||||||||||||||||||||
| 672 | $pattern->turns, $pattern->card_turns(card), $pattern->row_turns(row), | ||||||||||||||||||||||||||||||||||||||||||
| 673 | $pattern->turns(card, row) | ||||||||||||||||||||||||||||||||||||||||||
| 674 | $pattern->color, $pattern->card_color(card), $pattern->row_color(row), | ||||||||||||||||||||||||||||||||||||||||||
| 675 | $pattern->color(card,row) - gives color indices | ||||||||||||||||||||||||||||||||||||||||||
| 676 | $pattern->twist, $pattern->card_twist(card), $pattern->row_twist(row), $pattern->twist(card, row) | ||||||||||||||||||||||||||||||||||||||||||
| 677 | $pattern->dirty | ||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | # data modification | ||||||||||||||||||||||||||||||||||||||||||
| 680 | $pattern->SZ(card, value), $pattern->SZ(listref_of_SZ) | ||||||||||||||||||||||||||||||||||||||||||
| 681 | $pattern->threading(card, hole, color_index), $pattern->threading(card, listref_of_color_indices) | ||||||||||||||||||||||||||||||||||||||||||
| 682 | $pattern->start(card, hole), $pattern->start(listref_of_holes) | ||||||||||||||||||||||||||||||||||||||||||
| 683 | $pattern->color_table(color_index, color_value), $pattern->color_table(listref_of_color_values), | ||||||||||||||||||||||||||||||||||||||||||
| 684 | $pattern->color_table(undef, color_value) # add new color at end | ||||||||||||||||||||||||||||||||||||||||||
| 685 | $pattern->turns(card, row, turn), $pattern->card_turns(card, listref_of_turns), | ||||||||||||||||||||||||||||||||||||||||||
| 686 | $pattern->row_turns(row, listref_of_turns) | ||||||||||||||||||||||||||||||||||||||||||
| 687 | $pattern->dirty(value) | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | The Weaving::Tablet module provides data structures and routines to manipulate | ||||||||||||||||||||||||||||||||||||||||||
| 692 | tablet weaving patterns. It is limited to patterns using up to eight-holed | ||||||||||||||||||||||||||||||||||||||||||
| 693 | tablets with all holes threaded and that do not involve flipping tablets, | ||||||||||||||||||||||||||||||||||||||||||
| 694 | and use single turns only (no turning past more than one hole). | ||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | It supports an ASCII representation for persistent storage that is somewhat | ||||||||||||||||||||||||||||||||||||||||||
| 697 | human readable. | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | It provides routines to print information about the pattern in an ASCII | ||||||||||||||||||||||||||||||||||||||||||
| 700 | format. | ||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | =head2 Object Attributes | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | Some attributes are stored while others are computed or temporary. In the | ||||||||||||||||||||||||||||||||||||||||||
| 705 | discussion of attributes which care about the number of holes, the | ||||||||||||||||||||||||||||||||||||||||||
| 706 | discussion assumes four-holed cards. For different numbers of holes, the | ||||||||||||||||||||||||||||||||||||||||||
| 707 | description extends naturally. | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | The persistent attributes: | ||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | =item number_of_rows | ||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | The number of rows in the pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | =item number_of_cards | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | The number of cards (width) in the pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | =item number_of_holes | ||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | The number of holes in each card. This defaults to four and may be as | ||||||||||||||||||||||||||||||||||||||||||
| 724 | high as eight. | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | =item SZ | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | A list of (number_of_cards) elements, each of which is /[SZ]/. This | ||||||||||||||||||||||||||||||||||||||||||
| 729 | indicates how the tablet is threaded, either S or Z. | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | =item threading | ||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | A list of (number_of_cards) lists of four elements, each being a "color" | ||||||||||||||||||||||||||||||||||||||||||
| 734 | taken from the color_table. | ||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | Holes ABCD map to number 0123 for list indices. See the ASCII art below | ||||||||||||||||||||||||||||||||||||||||||
| 737 | for how the holes are considered arranged (subject to rotation) regardless | ||||||||||||||||||||||||||||||||||||||||||
| 738 | of S vs. Z threading. | ||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | <- fell | ||||||||||||||||||||||||||||||||||||||||||
| 741 | _________ | ||||||||||||||||||||||||||||||||||||||||||
| 742 | / \ | ||||||||||||||||||||||||||||||||||||||||||
| 743 | | A B | | ||||||||||||||||||||||||||||||||||||||||||
| 744 | | | | ||||||||||||||||||||||||||||||||||||||||||
| 745 | | D C | | ||||||||||||||||||||||||||||||||||||||||||
| 746 | \_________/ | ||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | =item start | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | A list of (number_of_cards) elements which indicates which hole is in | ||||||||||||||||||||||||||||||||||||||||||
| 751 | the A position (as shown above) for the starting positions. The values | ||||||||||||||||||||||||||||||||||||||||||
| 752 | are 0123. | ||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | =item turns | ||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||
| 756 | A list of (number_of_cards) lists of (number_of_rows) elements whose | ||||||||||||||||||||||||||||||||||||||||||
| 757 | values are /, \, or |, indicating the turning direction for each tablet for | ||||||||||||||||||||||||||||||||||||||||||
| 758 | each row. / denotes a forward turn; \ denotes a backwards turn; | denotes | ||||||||||||||||||||||||||||||||||||||||||
| 759 | no turn, i.e., an idling card. | ||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | =item color_table | ||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | A list of color specifications (whose specific format is undefined here). | ||||||||||||||||||||||||||||||||||||||||||
| 764 | The threading attribute uses indices into this table as its values. | ||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | The non-persistent and computed attributes: | ||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||
| 770 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | =item colors | ||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | A list parallel to turns whose values are the color of the thread visible | ||||||||||||||||||||||||||||||||||||||||||
| 775 | at that point. | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | =item twist | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | A list parallel to turns whose values are the amount of twist (in quarter-turns) | ||||||||||||||||||||||||||||||||||||||||||
| 780 | accumulated in the pattern up to that point. | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | =item file_name | ||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||
| 784 | The disk file name associated with this pattern, or undef if no file has been | ||||||||||||||||||||||||||||||||||||||||||
| 785 | specified. | ||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | =head2 Save file format | ||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | Saved patterns are meant to be human readable. To this end, they are | ||||||||||||||||||||||||||||||||||||||||||
| 792 | text files. | ||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||
| 794 | The first line gives the number of cards, rows, and holes. The next (number_of_rows) | ||||||||||||||||||||||||||||||||||||||||||
| 795 | lines are @turns, with row 0 at the bottom of the list. The next line is | ||||||||||||||||||||||||||||||||||||||||||
| 796 | @start, where the start positions are given as ABCD. | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | Next are the S/Z threading of each card, using S and Z as the symbols. | ||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||
| 800 | Next come (number_of_rows) lines giving the threadings. Each line is a list of | ||||||||||||||||||||||||||||||||||||||||||
| 801 | four numbers which indicate the color table entry for each thread. | ||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | Next comes the color table. Each line is a list of three numbers giving the | ||||||||||||||||||||||||||||||||||||||||||
| 804 | RGB value in the range 0 to 65535. The number of lines depends on the number | ||||||||||||||||||||||||||||||||||||||||||
| 805 | of different colors being used in the total pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | For example: | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | 20 cards 20 rows 4 holes | ||||||||||||||||||||||||||||||||||||||||||
| 810 | \///\\\/\\//\///\\\/ | ||||||||||||||||||||||||||||||||||||||||||
| 811 | /\\\///\//\\/\\\///\ | ||||||||||||||||||||||||||||||||||||||||||
| 812 | \/\\//\///\\\/\\//\/ | ||||||||||||||||||||||||||||||||||||||||||
| 813 | \\/\/\///\\\\\/\/\// | ||||||||||||||||||||||||||||||||||||||||||
| 814 | \\\/\///\///\\\/\/// | ||||||||||||||||||||||||||||||||||||||||||
| 815 | ///\///\/\///\\\/\\\ | ||||||||||||||||||||||||||||||||||||||||||
| 816 | //\///\//\\///\\\/\\ | ||||||||||||||||||||||||||||||||||||||||||
| 817 | /\///\/\\\/\\//\\\/\ | ||||||||||||||||||||||||||||||||||||||||||
| 818 | \///\\\/\\//\///\\\/ | ||||||||||||||||||||||||||||||||||||||||||
| 819 | /\\\///\//\\/\\\///\ | ||||||||||||||||||||||||||||||||||||||||||
| 820 | \/\\//\///\\\/\\//\/ | ||||||||||||||||||||||||||||||||||||||||||
| 821 | \\/\/\///\\\\\/\/\// | ||||||||||||||||||||||||||||||||||||||||||
| 822 | \\\/\///\///\\\/\/// | ||||||||||||||||||||||||||||||||||||||||||
| 823 | ///\///\/\///\\\/\\\ | ||||||||||||||||||||||||||||||||||||||||||
| 824 | //\///\//\\///\\\/\\ | ||||||||||||||||||||||||||||||||||||||||||
| 825 | /\///\/\\\/\\//\\\/\ | ||||||||||||||||||||||||||||||||||||||||||
| 826 | \///\\\/\\//\///\\\/ | ||||||||||||||||||||||||||||||||||||||||||
| 827 | /\\\///\//\\/\\\///\ | ||||||||||||||||||||||||||||||||||||||||||
| 828 | \/\\//\///\\\/\\//\/ | ||||||||||||||||||||||||||||||||||||||||||
| 829 | \\/\/\///\\\\\/\/\// | ||||||||||||||||||||||||||||||||||||||||||
| 830 | ADABCDADABCDADABCDAD | ||||||||||||||||||||||||||||||||||||||||||
| 831 | SSSSSSSSSSSSSSSSSSSS | ||||||||||||||||||||||||||||||||||||||||||
| 832 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 833 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 834 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 836 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 837 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 838 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 839 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 840 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 841 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 842 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 843 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 844 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 845 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 846 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 847 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 848 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 849 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 850 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 851 | 0,1,2,3 | ||||||||||||||||||||||||||||||||||||||||||
| 852 | 65535,0,0 | ||||||||||||||||||||||||||||||||||||||||||
| 853 | 0,65535,0 | ||||||||||||||||||||||||||||||||||||||||||
| 854 | 0,0,65535 | ||||||||||||||||||||||||||||||||||||||||||
| 855 | 65535,65535,0 | ||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||
| 857 | =head2 Routines | ||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||
| 859 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | =item new_from_file(file) | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | Load an existing pattern from the specified file. Returns undef if the | ||||||||||||||||||||||||||||||||||||||||||
| 864 | file is not specified, is not readable, or cannot be loaded. | ||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | =item new_from_scratch(cards, rows) | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | Create a pattern with the specified number of cards and rows (both defaulting | ||||||||||||||||||||||||||||||||||||||||||
| 869 | to 1). This assumes that the pattern uses four colors: black, red, green, blue. | ||||||||||||||||||||||||||||||||||||||||||
| 870 | It sets the cards to all turn forward, threaded S, and arranged to make | ||||||||||||||||||||||||||||||||||||||||||
| 871 | diagonals. | ||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||
| 873 | =item load_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | Attempts to load the pattern from $self->{file_name}. If the load fails for any | ||||||||||||||||||||||||||||||||||||||||||
| 876 | reason it returns false, else true. It calls color_pattern and twist_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 877 | before returning. | ||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | =item save_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | Attempts to write the pattern to $self->{file_name}. If the save fails for any | ||||||||||||||||||||||||||||||||||||||||||
| 882 | reason it returns false, else true. | ||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | =item color_pattern(cardlist) | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | Computes $self->{color} by walking each card to see what color is on top at | ||||||||||||||||||||||||||||||||||||||||||
| 887 | each point in the pattern. If cardlist is specified, limit recoloring to | ||||||||||||||||||||||||||||||||||||||||||
| 888 | specified cards. | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | =item twist_pattern(cardlist) | ||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | Computes the accumulated twist in quarter-turn units at each point in the | ||||||||||||||||||||||||||||||||||||||||||
| 893 | pattern. If cardlist is specified, limit calculation to | ||||||||||||||||||||||||||||||||||||||||||
| 894 | specified cards. | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | =item print_twist(rowlist) | ||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | "Prints" the accumulated twist for the last row or each row specified in | ||||||||||||||||||||||||||||||||||||||||||
| 899 | the rowlist. | ||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||
| 901 | In a scalar context, print_twist returns a string suitable | ||||||||||||||||||||||||||||||||||||||||||
| 902 | for direct printing. The string contains one line for each row specified. | ||||||||||||||||||||||||||||||||||||||||||
| 903 | Each line is a comma-separated list of values. | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | In a list context, print_twist returns a list of lists. | ||||||||||||||||||||||||||||||||||||||||||
| 906 | Each inner list is a list of twist values for the selected row. | ||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||
| 908 | For example: $pattern->print_twist(10,11) will return a list of two lists in | ||||||||||||||||||||||||||||||||||||||||||
| 909 | a list context | ||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | =item insert_pick(rowspec...) | ||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||
| 913 | Add picks to the pattern. Row numbers begin with 0. | ||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | $pattern->insert_pick() inserts a new row at the end, with all cards turning | ||||||||||||||||||||||||||||||||||||||||||
| 916 | forward. | ||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | $pattern->insert_pick([]number]) inserts a new row after row (number). Specify | ||||||||||||||||||||||||||||||||||||||||||
| 919 | -1 to insert new row at beginning. All cards will be turning forward. | ||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | $pattern->insert_pick([]number, turns]) inserts a new row with the turning | ||||||||||||||||||||||||||||||||||||||||||
| 922 | specified. Turning is given as a string of /, \, and |. The turns is padded with | ||||||||||||||||||||||||||||||||||||||||||
| 923 | / if too short; excess cards are ignored. | ||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | insert_pick may be called with multiple sets of rows and turnings. | ||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | =item insert_card(after, turns...) | ||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||
| 929 | Add a new tablet to the pattern. The variations are analagous to insert_pick. | ||||||||||||||||||||||||||||||||||||||||||
| 930 | The tablet is presumed to be S threaded starting with hole A. | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | =item delete_row(rowlist) | ||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | Delete the specified rows from the pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||
| 936 | =item delete_card(cardlist) | ||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | Delete the specified card from the pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | =item duplicate_row(from, to) | ||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||
| 942 | Creates a new row after the specified row with the same turnings as the | ||||||||||||||||||||||||||||||||||||||||||
| 943 | source row. Omitting the 'to' argument places the new row at the end. | ||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | =item duplicate_card(card, after) | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | Creates a new tablet after the specified tablet with the same turnings as the | ||||||||||||||||||||||||||||||||||||||||||
| 948 | source tablet. | ||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||
| 952 | =head1 BUGS AND LIMITATIONS | ||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | No bugs have been reported. | ||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||||||||||||||||
| 957 | C<bug-weaving-tablet@rt.cpan.org>, or through the web interface at | ||||||||||||||||||||||||||||||||||||||||||
| 958 | L<http://rt.cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | Michael Houghton C<< <herveus@cpan.org> >> | ||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | =head1 LICENCE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||
| 968 | Copyright (c) 1999-2009, Michael Houghton C<< <herveus@cpan.org> >>. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||
| 970 | This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||
| 971 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | =head1 DISCLAIMER OF WARRANTY | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | ||||||||||||||||||||||||||||||||||||||||||
| 977 | FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | ||||||||||||||||||||||||||||||||||||||||||
| 978 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | ||||||||||||||||||||||||||||||||||||||||||
| 979 | PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER | ||||||||||||||||||||||||||||||||||||||||||
| 980 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||||||||||||||||||||||||||||||||||||||||||
| 981 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE | ||||||||||||||||||||||||||||||||||||||||||
| 982 | ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH | ||||||||||||||||||||||||||||||||||||||||||
| 983 | YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL | ||||||||||||||||||||||||||||||||||||||||||
| 984 | NECESSARY SERVICING, REPAIR, OR CORRECTION. | ||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||||||||||||||||||||||||||||||||||||||||||
| 987 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | ||||||||||||||||||||||||||||||||||||||||||
| 988 | REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE | ||||||||||||||||||||||||||||||||||||||||||
| 989 | LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, | ||||||||||||||||||||||||||||||||||||||||||
| 990 | OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE | ||||||||||||||||||||||||||||||||||||||||||
| 991 | THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING | ||||||||||||||||||||||||||||||||||||||||||
| 992 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A | ||||||||||||||||||||||||||||||||||||||||||
| 993 | FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF | ||||||||||||||||||||||||||||||||||||||||||
| 994 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF | ||||||||||||||||||||||||||||||||||||||||||
| 995 | SUCH DAMAGES. | ||||||||||||||||||||||||||||||||||||||||||