2013-02-09 10:49:22 -08:00
|
|
|
package DDG::Goodie::Paper;
|
2014-06-30 18:24:26 -07:00
|
|
|
# ABSTRACT: Return the dimensions of a defined paper size
|
2013-02-09 10:49:22 -08:00
|
|
|
|
2015-02-22 12:09:29 -08:00
|
|
|
use strict;
|
2013-02-09 10:49:22 -08:00
|
|
|
use DDG::Goodie;
|
2015-05-29 15:18:03 -07:00
|
|
|
use YAML::XS 'LoadFile';
|
2013-02-09 10:49:22 -08:00
|
|
|
|
2014-06-30 18:24:26 -07:00
|
|
|
zci answer_type => "paper";
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
|
|
|
triggers any => 'paper size', 'dimensions', 'paper dimension', 'paper dimensions';
|
|
|
|
|
|
|
|
primary_example_queries 'letter paper size';
|
|
|
|
secondary_example_queries 'a1 paper size', 'a9 paper dimension';
|
|
|
|
description 'Lookup the size of standard paper sizes';
|
|
|
|
name 'Paper';
|
|
|
|
code_url
|
|
|
|
'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Paper.pm';
|
|
|
|
category 'conversions';
|
|
|
|
topics 'special_interest';
|
2015-01-07 10:24:47 -08:00
|
|
|
attribution github => ['loganom', 'Logan McCamon'],
|
|
|
|
twitter => ['loganmccamon', 'Logan McCamon'],
|
|
|
|
github => ['mattlehnig', 'Matt Lehnig'];
|
2014-06-30 18:24:26 -07:00
|
|
|
|
2015-05-29 15:18:03 -07:00
|
|
|
my $sizes = LoadFile(share('sizes.yml'));
|
2013-02-09 10:49:22 -08:00
|
|
|
|
|
|
|
handle query_lc => sub {
|
2014-07-01 10:22:34 -07:00
|
|
|
return unless my ($s, $l, $n) = $_ =~ /^((?:(a|b|c)(\d{0,2}))|legal|letter|junior\s*legal|ledger|tabloid|hagaki)\s+paper\s+(?:size|dimm?ensions?)$/i;
|
2013-02-09 10:49:22 -08:00
|
|
|
|
2014-10-14 11:39:20 -07:00
|
|
|
my $value = $sizes->{$s};
|
|
|
|
return unless $value;
|
2013-02-09 10:49:22 -08:00
|
|
|
|
2014-10-14 11:39:20 -07:00
|
|
|
$s = uc $s if defined $n;
|
2013-02-09 10:49:22 -08:00
|
|
|
|
2014-10-14 11:39:20 -07:00
|
|
|
return $value,
|
|
|
|
structured_answer => {
|
|
|
|
input => [$s],
|
2015-01-09 00:03:10 -08:00
|
|
|
operation => 'Paper size',
|
2014-10-14 11:39:20 -07:00
|
|
|
result => $value
|
|
|
|
};
|
2013-02-09 10:49:22 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
1;
|