Class ZOOM::Connection

Abstract

The Connection object is a session with a target.

Inherits from: Object ← ZOOM::Connection .

Included in: ZOOM .

Index: connect get_option new open search set_option

Class methods
newnew(options=nil)
 

Creates a new connection object, but does not establish a network connection immediately, allowing you to specify options before (if given). You can thus establish the connection using ZOOM::Connection#connect.

  • options: options for the connection, as a Hash object.

  • Returns: a newly created ZOOM::Connection object.

openopen(host, port=nil) { |conn| ... }
 

A convenience method that creates a new connection and attempts to establish a network connection to the given target, basically calling ZOOM::Connection.new and ZOOM::Connection#connect.

If a block is given, then it will be called once the connection is established, passing a reference to the connection object as a parameter, and destroying the connection automatically at the end of the block. With no block, this method just returns the connection object.

  • port: network port of the target to connect to.

  • host: hostname of the target to connect to.

  • Returns: a newly created ZOOM::Connection object.

Instance methods
connectconnect(host, port=nil)
 

Establishes a network connection to the target specified by the given arguments. If no port is given, 210 will be used. A colon in the host string denotes the beginning of a port number. If the host string includes a slash, the following part specifies a database for the connection.

You can also prefix the host string with a scheme followed by a colon. The default scheme is tcp (Z39.50 protocol). The scheme http selects SRW over HTTP.

This method raises an exception on error.

  • port: network port of the target to connect to.

  • host: hostname of the target to connect to.

  • Returns: self.

get_optionget_option(key)
 

Gets the value of a connection's option.

  • key: the name of the option, as a string.

  • Returns: the value of the given option, as a string, integer or boolean.

searchsearch(criterion)
 

Searches the connection from the given criterion. You can either create and pass a reference to a ZOOM::Query object, or you can simply pass a string that represents a PQF query.

This method raises an exception on error.

  • criterion: the search criterion, either as a ZOOM::Query object or as a string, representing a PQF query.

  • Returns: a result set from the search, as a ZOOM::ResultSet object, empty if no results were found.

set_optionset_option(key, value)
 

Sets an option on the connection.

  • value: the value of this option (as a string, integer or boolean).

  • key: the name of the option, as a string.

  • Returns: self.