Bing::Search::Result::InstantAnswer - Instant answers from Bing


Bing-Search documentation Contained in the Bing-Search distribution.

Index


Code Index:

NAME

Top

Bing::Search::Result::InstantAnswer - Instant answers from Bing

METHODS

Top

Url

A URI object linking to a more detailed answer, or at least, the source material.

Attribution

The "source" for the instant answer. Nto always present.

ContentType

The type of instant answer you got. Is generally an "Encarta." or "FlightStatus." type.

Title

For most cases, the title is also the query, as understood by Bing.

Answer

Contains 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.

AUTHOR

Top

Dave Houston, dhouston@cpan.org, 2010

LICENSE

Top

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;