File Coverage

blib/lib/Arithmetic/PaperAndPencil/Char.pm
Criterion Covered Total %
statement 22 24 91.6
branch n/a
condition n/a
subroutine 9 11 81.8
pod 0 4 0.0
total 31 39 79.4


line stmt bran cond sub pod time code
1             # -*- encoding: utf-8; indent-tabs-mode: nil -*-
2              
3              
4 3     3   43 use 5.38.0;
  3         12  
5 3     3   17 use utf8;
  3         6  
  3         19  
6 3     3   106 use strict;
  3         7  
  3         78  
7 3     3   14 use warnings;
  3         5  
  3         157  
8 3     3   17 use open ':encoding(UTF-8)';
  3         6  
  3         34  
9 3     3   384 use feature qw/class/;
  3         7  
  3         444  
10 3     3   49 use experimental qw/class/;
  3         26  
  3         40  
11              
12             class Arithmetic::PaperAndPencil::Char 0.01;
13              
14             field $char :param ;
15             field $underline = 0;
16             field $strike = 0;
17             field $read = 0;
18             field $write = 0;
19              
20             method pseudo_html {
21             my $result = $char;
22             if ($write) {
23             $result = "$result";
24             }
25             elsif ($read) {
26             # "elsif", because only one of (read|write) will be rendered, and write is more important than read
27             $result = "$result";
28             }
29             if ($strike) {
30             $result = "$result";
31             }
32             if ($underline) {
33             $result = "$result";
34             }
35             return $result;
36             }
37             method set_char ($c) { $char = $c; }
38             method set_underline($n) { $underline = $n; }
39             method set_strike( $n) { $strike = $n; }
40             method set_read( $n) { $read = $n; }
41             method set_write( $n) { $write = $n; }
42             method char { $char }
43             method underline { $underline }
44             method strike { $strike }
45             method read { $read }
46             method write { $write }
47              
48 342     342 0 1712 sub space_char { return Arithmetic::PaperAndPencil::Char->new(char => ' ' ); }
49 18     18 0 110 sub pipe_char { return Arithmetic::PaperAndPencil::Char->new(char => '|' ); }
50 0     0 0   sub slash_char { return Arithmetic::PaperAndPencil::Char->new(char => '/' ); }
51 0     0 0   sub backslash_char { return Arithmetic::PaperAndPencil::Char->new(char => '\\'); }
52              
53             'π'; # End of Arithmetic::PaperAndPencil::Char
54              
55             =head1 NAME
56              
57             Arithmetic::PaperAndPencil::Char - individual characters when rendering an arithmetic operation
58              
59             =head1 VERSION
60              
61             Version 0.01
62              
63             =head1 DESCRIPTION
64              
65             This class should not be used directly. It is meant to be a utility
66             module for C.
67              
68             C is a class storing the characters
69             when rendering an arithmetic operation. Beside the character itself,
70             it stores information about the decoration of the char: underline,
71             strike, etc.
72              
73             =head1 EXPORT
74              
75             None. The IC<_char> functions must be fully qualified when called.
76              
77             =head1 SUBROUTINES/METHODS
78              
79             =head2 pseudo_html
80              
81             Renders the char with its attributes (underline, etc).
82              
83             =head1 AUTHOR
84              
85             Jean Forget, C<< >>
86              
87             =head1 BUGS
88              
89             Please report any bugs or feature requests to
90             C, or through the web
91             interface at
92             L.
93             I will be notified, and then you'll automatically be notified of
94             progress on your bug as I make changes.
95              
96             =head1 SUPPORT
97              
98             You can find documentation for this module with the perldoc command.
99              
100             perldoc Arithmetic::PaperAndPencil
101              
102             You can also look for information at:
103              
104             =over 4
105              
106             =item * RT: CPAN's request tracker (report bugs here)
107              
108             L
109              
110             =item * CPAN Ratings
111              
112             L
113              
114             =item * Search CPAN
115              
116             L
117              
118             =back
119              
120              
121             =head1 ACKNOWLEDGEMENTS
122              
123              
124             =head1 LICENSE AND COPYRIGHT
125              
126             This software is Copyright (c) 2024 by jforget.
127              
128             This is free software, licensed under:
129              
130             The Artistic License 2.0 (GPL Compatible)
131              
132