1 (** Wrapper around Perl [Net::Google] class. *)
2 (* Copyright (C) 2003 Merjis Ltd.
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this library; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
19 $Id: pl_Net_Google.ml,v 1.4 2008-03-01 13:02:21 rich Exp $
24 open Pl_Net_Google_Cache
25 open Pl_Net_Google_Search
26 open Pl_Net_Google_Spelling
28 let _ = eval "use Net::Google"
30 let may f = function None -> () | Some v -> f v
36 method search ?key ?starts_at ?max_results ?lr ?ie ?oe ?safe ?filter () =
39 args := sv_of_string "key" :: sv_of_string v :: !args) key;
41 args := sv_of_string "starts_at" :: sv_of_int v :: !args) starts_at;
43 args := sv_of_string "max_results" :: sv_of_int v :: !args)
46 args := sv_of_string "lr" :: sv_of_string v :: !args) lr;
48 args := sv_of_string "ie" :: sv_of_string v :: !args) ie;
50 args := sv_of_string "oe" :: sv_of_string v :: !args) oe;
52 args := sv_of_string "safe" :: sv_of_bool v :: !args) safe;
54 args := sv_of_string "filter" :: sv_of_bool v :: !args) filter;
55 let sv = call_method sv "search" !args in
56 new net_google_search sv
58 method spelling ?key ?phrase ?debug () =
61 args := sv_of_string "key" :: sv_of_string v :: !args) key;
63 args := sv_of_string "phrase" :: sv_of_string v :: !args) phrase;
65 args := sv_of_string "debug" :: sv_of_int v :: !args) debug;
66 let sv = call_method sv "spelling" !args in
67 new net_google_spelling sv
69 method cache ?key ?url ?debug () =
72 args := sv_of_string "key" :: sv_of_string v :: !args) key;
74 args := sv_of_string "url" :: sv_of_string v :: !args) url;
76 args := sv_of_string "debug" :: sv_of_int v :: !args) debug;
77 let sv = call_method sv "cache" !args in
78 new net_google_cache sv
82 let new_ ?key ?debug () =
85 args := sv_of_string "key" :: sv_of_string v :: !args) key;
87 args := sv_of_string "debug" :: sv_of_int v :: !args) debug;
88 let sv = call_class_method "Net::Google" "new" !args in