line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Math::Tutor::Role::VulFracExercise; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
833
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
App::Math::Tutor::Role::VulFracExercise - role for exercises in vulgar fraction |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
13
|
1
|
|
|
1
|
|
316
|
use MooX::Options; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with "App::Math::Tutor::Role::Exercise", "App::Math::Tutor::Role::VulFrac"; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 format |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Specifies format of numerator/denominator |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
option format => ( |
28
|
|
|
|
|
|
|
is => "ro", |
29
|
|
|
|
|
|
|
doc => "specifies format of numerator/denominator", |
30
|
|
|
|
|
|
|
long_doc => "Allow specifying the format of the numerator/denominator " |
31
|
|
|
|
|
|
|
. "whereby any digit is typed with 'n' as placeholder:\n\n" |
32
|
|
|
|
|
|
|
. "\t--format 5nnn/nn\n\n" |
33
|
|
|
|
|
|
|
. "creates vulgar fractions from 5999/99 .. 0002/02.\n\n" |
34
|
|
|
|
|
|
|
. "Default: 100/100", |
35
|
|
|
|
|
|
|
isa => sub { |
36
|
|
|
|
|
|
|
defined( $_[0] ) |
37
|
|
|
|
|
|
|
and !ref $_[0] |
38
|
|
|
|
|
|
|
and $_[0] !~ m,^\d?n+(?:/\d?n+)?$, |
39
|
|
|
|
|
|
|
and die("Invalid format"); |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
coerce => sub { |
42
|
|
|
|
|
|
|
defined( $_[0] ) |
43
|
|
|
|
|
|
|
or return [ 100, 100 ]; |
44
|
|
|
|
|
|
|
ref $_[0] eq "ARRAY" and return $_[0]; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my ( $fmta, $fmtb ) = ( $_[0] =~ m,^(\d?n+)(?:/(\d?n+))?$, ); |
47
|
|
|
|
|
|
|
defined $fmtb or $fmtb = $fmta; |
48
|
|
|
|
|
|
|
my $starta = "1"; |
49
|
|
|
|
|
|
|
my $startb = "1"; |
50
|
|
|
|
|
|
|
$fmta =~ s/^(\d)(.*)/$2/ and $starta = $1; |
51
|
|
|
|
|
|
|
$fmtb =~ s/^(\d)(.*)/$2/ and $startb = $1; |
52
|
|
|
|
|
|
|
my $maxa = $starta . "0" x length($fmta); |
53
|
|
|
|
|
|
|
my $maxb = $startb . "0" x length($fmtb); |
54
|
|
|
|
|
|
|
[ $maxa, $maxb ]; |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
default => sub { return [ 100, 100 ]; }, |
57
|
|
|
|
|
|
|
format => "s", |
58
|
|
|
|
|
|
|
short => "f", |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 negativable |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Controls whether fractions can become less 0 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
option negativable => ( |
68
|
|
|
|
|
|
|
is => "ro", |
69
|
|
|
|
|
|
|
doc => "Controls whether fractions can become less 0", |
70
|
|
|
|
|
|
|
default => sub { 0 }, |
71
|
|
|
|
|
|
|
negativable => 1, |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Copyright 2010-2014 Jens Rehsack. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
79
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
80
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |