summaryrefslogtreecommitdiff
path: root/lib/Data/QRCode.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/QRCode.pm')
-rw-r--r--lib/Data/QRCode.pm47
1 files changed, 44 insertions, 3 deletions
diff --git a/lib/Data/QRCode.pm b/lib/Data/QRCode.pm
index 649e1f9..37cab64 100644
--- a/lib/Data/QRCode.pm
+++ b/lib/Data/QRCode.pm
@@ -8,6 +8,28 @@ use namespace::clean;
# ABSTRACT: qrcodes in C
# VERSION
+=head1 SYNOPSIS
+
+ use Data::QRCode;
+
+ my $qr = Data::QRCode->new('some string');
+
+ my $text_matrix = $qr->map(
+ sub { $_[0]->{color} ? '*' : ' ' }
+ );
+
+ print "$_\n" for map { join '',@{$_} } @{$text_matrix};
+
+=head1 DESCRIPTION
+
+This class exposes a simple interface to the L<<
+C<qrencode>|http://fukuchi.org/works/qrencode/index.html.en >>
+library.
+
+=attr C<error_correction_level>
+
+=cut
+
has error_correction_level => (
is => 'ro',
isa => QRCodeEC,
@@ -15,6 +37,10 @@ has error_correction_level => (
default => Data::QRCode::Input::ECLEVEL_M,
);
+=attr C<mode>
+
+=cut
+
has mode => (
is => 'ro',
isa => QRCodeMode,
@@ -22,12 +48,23 @@ has mode => (
default => Data::QRCode::Input::MODE_8,
);
+=attr C<version>
+
+=cut
+
has version => (
is => 'rwp',
isa => Int,
default => 0,
);
+=attr C<input_data>
+
+=for Pod::Coverage
+BUILDARGS
+
+=cut
+
has input_data => (
is => 'ro',
required => 1,
@@ -49,7 +86,7 @@ has _result => (
handles => [ qw(width data_at) ],
);
-sub _build__result {
+sub _build__result { ## no critic(ProhibitUnusedPrivateSubroutines)
my ($self) = @_;
my $input = Data::QRCode::Input->new();
@@ -63,7 +100,11 @@ sub _build__result {
return $ret;
}
-sub map {
+=method C<map>
+
+=cut
+
+sub map { ## no critic(ProhibitBuiltinHomonyms)
my ($self,$code) = @_;
my $r = $self->_result;
@@ -74,7 +115,7 @@ sub map {
# use the internal function to avoid re-checking the x/y
# bounds
my $raw_data = $r->_data_at($x,$y);
- my $hash_data = Data::QRCode::Result::_data_hash($raw_data);
+ my $hash_data = Data::QRCode::Result::_data_hash($raw_data); ## no critic(ProtectPrivateSubs)
push @{$result[-1]}, $code->($hash_data,$raw_data);
}