goodie to show paper sizes

master
matt lehning 2013-01-29 14:21:16 -05:00
parent 3e0a1ed7d6
commit 427a36f7bc
2 changed files with 77 additions and 0 deletions

56
lib/DDG/Goodie/Paper.pm Normal file
View File

@ -0,0 +1,56 @@
package DDG::Goodie::Paper;
use DDG::Goodie;
triggers any => 'paper', 'size';
handle query_lc => sub {
return unless my ($s, $l, $n) = $_ =~ /^((a|b|c)(\d{0,2})) paper (?:size|dimensions?)$/i;
last if($n > 10);
my $key = $s;
my $value;
my %hash = (
"a0" => "841mm x 1189mm 33.11in x 46.81in",
"a1" => "594mm x 841mm 23.39in x 33.11in",
"a2" => "420mm x 594mm 16.54in x 23.39in",
"a3" => "297mm x 420mm 11.69in x 16.54in",
"a4" => "210mm x 297mm 8.27in x 11.69in",
"a5" => "148mm x 210mm 5.83in x 8.27in",
"a6" => "105mm x 148mm 4.13in x 5.83in",
"a7" => "74mm x 105mm 2.91in x 4.13in",
"a8" => "52mm x 74mm 2.05in x 2.91in",
"a9" => "37mm x 52mm 1.46in x 2.05in",
"a10" => "26mm x 37mm 1.02in x 1.46in",
"b0" => "1000mm x 1414mm 39.37in x 55.67in",
"b1" => "707mm x 1000mm 27.83in x 39.37in",
"b2" => "500mm x 707mm 19.69in x 27.83in",
"b3" => "353mm x 500mm 13.90in x 19.69in",
"b4" => "250mm x 353mm 9.84in x 13.90in",
"b5" => "176mm x 250mm 6.93in x 9.84in",
"b6" => "125mm x 176mm 4.92in x 6.93in",
"b7" => "88mm x 125mm 3.46in x 4.92in",
"b8" => "62mm x 88mm 2.44in x 3.46in",
"b9" => "44mm x 62mm 1.73in x 2.44in",
"b10" => "31mm x 44mm 1.22in x 1.73in",
"c0" => "917mm x 1297mm 36.10in x 51.06in",
"c1" => "648mm x 917mm 25.51in x 36.10in",
"c2" => "458mm x 648mm 18.03in x 25.51in",
"c3" => "324mm x 458mm 12.76in x 18.03in",
"c4" => "229mm x 324mm 9.02in x 12.76in",
"c5" => "162mm x 229mm 6.38in x 9.02in",
"c6" => "114mm x 162mm 4.49in x 6.38in",
"c7" => "81mm x 114mm 3.19in x 4.49in",
"c8" => "57mm x 81mm 2.24in x 3.19in",
"c9" => "40mm x 57mm 1.57in x 2.24in",
"c10" => "28mm x 40mm 1.10in x 1.57in"
);
$value = $hash{$key};
return $value;
};
1;

21
t/Paper.t Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
zci answer_type => 'paper';
zci is_cached => 0;
ddg_goodie_test(
[qw(
DDG::Goodie::Paper
)],
'a0 paper size' => test_zci('841mm x 1189mm 33.11in x 46.81in'),
'c10 paper dimension' => test_zci('28mm x 40mm 1.10in x 1.57in'),
'b10 paper dimensions' => test_zci('31mm x 44mm 1.22in x 1.73in'),
);
done_testing;