zeroclickinfo-goodies/lib/DDG/Goodie/Constants.pm

36 lines
1.0 KiB
Perl
Raw Normal View History

2015-04-06 07:07:54 -07:00
package DDG::Goodie::Constants;
# ABSTRACT: Various Math and Physics constants.
use DDG::Goodie;
use YAML::XS qw( LoadFile );
2015-04-06 07:07:54 -07:00
zci answer_type => "constants";
zci is_cached => 1;
name "Constants";
description "Succinct explanation of what this instant answer does";
primary_example_queries "first example query", "second example query";
secondary_example_queries "optional -- demonstrate any additional triggers";
category "formulas";
topics "math";
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Constants.pm";
attribution github => ["hemanth", "Hemanth.HM"],
twitter => "gnumanth";
my $constants = LoadFile(share("constants.yml"));
my @triggers = keys %{$constants};
2015-04-06 07:07:54 -07:00
triggers startend => @triggers;
2015-04-06 07:07:54 -07:00
# Handle statement
handle query_lc => sub {
return unless my $val = $constants->{$_}; #lookup hash using query as key
return $val, structured_answer => {
input => [],
operation => 'Constants',
result => $val
};
2015-04-06 07:07:54 -07:00
};
1;