| Bing-Search documentation | Contained in the Bing-Search distribution. |
Bing::Search::Result::InstantAnswer - Instant answers from Bing
UrlA URI object linking to a more detailed answer, or at least, the source material.
AttributionThe "source" for the instant answer. Nto always present.
ContentTypeThe type of instant answer you got. Is generally an "Encarta." or "FlightStatus." type.
TitleFor most cases, the title is also the query, as understood by Bing.
AnswerContains a specific object with your answer. Depending on the type
of answer, it may be either a Bing::Search::Result::InstantAnswer::Encarta
or Bing::Search::Result::InstantAnswer::FlightStatus object. You
should use ref to check which one you got.
Dave Houston, dhouston@cpan.org, 2010
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.
| Bing-Search documentation | Contained in the Bing-Search distribution. |
package Bing::Search::Result::InstantAnswer; use Moose; use Bing::Search::Result::InstantAnswer::Encarta; use Bing::Search::Result::InstantAnswer::FlightStatus; extends 'Bing::Search::Result'; with 'Bing::Search::Role::Types::UrlType'; with qw( Bing::Search::Role::Result::Url Bing::Search::Role::Result::Attribution Bing::Search::Role::Result::ContentType Bing::Search::Role::Result::Title ); has 'Answer' => ( is => 'rw', ); before '_populate' => sub { my $self = shift; my $data = $self->data; my $results = delete $data->{InstantAnswerSpecificData}; my $obj; if( exists $results->{Encarta} ) { $obj = Bing::Search::Result::InstantAnswer::Encarta->new; $obj->data( $results->{Encarta} ); } elsif( exists $results->{FlightStatus} ) { $obj = Bing::Search::Result::InstantAnswer::FlightStatus->new; $obj->data( $results->{FlightStatus} ); } $obj->_populate; $self->Answer( $obj ); }; __PACKAGE__->meta->make_immutable;