s/rs/syntax
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Task / Retrieve.pm
1 # $Id: Retrieve.pm,v 1.6 2007-05-09 11:05:30 mike Exp $
2
3 package ZOOM::IRSpy::Task::Retrieve;
4
5 use 5.008;
6 use strict;
7 use warnings;
8
9 use ZOOM::IRSpy::Task;
10 our @ISA = qw(ZOOM::IRSpy::Task);
11
12 =head1 NAME
13
14 ZOOM::IRSpy::Task::Retrieve - a searching task for IRSpy
15
16 =head1 SYNOPSIS
17
18  ## to follow
19
20 =head1 DESCRIPTION
21
22  ## to follow
23
24 =cut
25
26 sub new {
27     my $class = shift();
28     my($rs) = shift();
29     my($index0) = shift();
30
31     my $this = $class->SUPER::new(@_);
32     $this->{rs} = $rs;
33     $this->{index0} = $index0;
34     # Save initial record-syntax for render()'s benefit
35     $this->{syntax} = $this->{options}->{preferredRecordSyntax};
36
37     return $this;
38 }
39
40 sub run {
41     my $this = shift();
42
43     $this->set_options();
44
45     my $conn = $this->conn();
46     $conn->connect($conn->option("host"));
47
48     my $rs = $this->{rs};
49     my $index0 = $this->{index0};
50     $this->irspy()->log("irspy_task", $conn->option("host"),
51                         " retrieving record $index0 from $rs");
52     $rs->records($index0, 1, 0); # requests record
53     warn "no ZOOM-C level events queued by $this"
54         if $conn->is_idle();
55
56     $this->set_options();
57 }
58
59 sub render {
60     my $this = shift();
61     my $syntax = $this->{syntax};
62     $syntax = defined $syntax ? "'$syntax'" : "undef";
63     return ref($this) . "(" . $this->{index0} . ", $syntax)";
64 }
65
66 use overload '""' => \&render;
67
68
69 =head1 SEE ALSO
70
71 ZOOM::IRSpy
72
73 =head1 AUTHOR
74
75 Mike Taylor, E<lt>mike@indexdata.comE<gt>
76
77 =head1 COPYRIGHT AND LICENSE
78
79 Copyright (C) 2006 by Index Data ApS.
80
81 This library is free software; you can redistribute it and/or modify
82 it under the same terms as Perl itself, either Perl version 5.8.7 or,
83 at your option, any later version of Perl 5 you may have available.
84
85 =cut
86
87 1;