Class | EstraierPure::Node
In: | estraierpure.rb
Parent: | Object

Abstraction of connection to P2P node.

### Methods

admins cache_usage doc_num edit_doc etch_doc etch_doc_by_uri get_doc get_doc_attr get_doc_attr_by_uri get_doc_by_uri label links name new optimize out_doc out_doc_by_uri put_doc search set_auth set_link set_proxy set_snippet_width set_timeout set_url set_user size status sync uri_to_id users word_num

### Public Class methods

new()

Create a node connection object.

### Public Instance methods

admins()

Get an array of names of administrators. The return value is an array object of names of administrators. On error, `nil’ is returned.

cache_usage()

Get the usage ratio of the cache. The return value is the usage ratio of the cache. On error, -1.0 is returned.

doc_num()

Get the number of documents. The return value is the number of documents. On error, -1 is returned.

edit_doc(doc)

Edit attributes of a document. `doc’ specifies a document object. The return value is true if success, else it is false.

etch_doc(id)

Extract keywords of a document. `id’ specifies the ID number of a registered document. The return value is a hash object of keywords and their scores in decimal string or `nil’ on error.

etch_doc_by_uri(uri)

Extract keywords of a document specified by URI. `uri’ specifies the URI of a registered document. The return value is a hash object of keywords and their scores in decimal string or `nil’ on error.

get_doc(id)

Retrieve a document. `id’ specifies the ID number of a registered document. The return value is a document object. On error, `nil’ is returned.

get_doc_attr(id, name)

Retrieve the value of an attribute of a document. `id’ specifies the ID number of a registered document. `name’ specifies the name of an attribute. The return value is the value of the attribute or `nil’ if it does not exist.

get_doc_attr_by_uri(uri, name)

Retrieve the value of an attribute of a document specified by URI. `uri’ specifies the URI of a registered document. `name’ specifies the name of an attribute. The return value is the value of the attribute or `nil’ if it does not exist.

get_doc_by_uri(uri)

Retrieve a document. `uri’ specifies the URI of a registered document. The return value is a document object. On error, `nil’ is returned.

label()

Get the label. The return value is the label. On error, `nil’ is returned.

links()

Get an array of expressions of links. The return value is an array object of expressions of links. Each element is a TSV string and has three fields of the URL, the label, and the score. On error, `nil’ is returned.

name()

Get the name. The return value is the name. On error, `nil’ is returned.

optimize()

Optimize the database. The return value is true if success, else it is false.

out_doc(id)

Remove a document. `id’ specifies the ID number of a registered document. The return value is true if success, else it is false.

out_doc_by_uri(uri)

     Remove a document specified by URI.

`uri’ specifies the URI of a registered document. The return value is true if success, else it is false.

put_doc(doc)

Add a document. `doc’ specifies a document object. The document object should have the URI attribute. The return value is true if success, else it is false.

search(cond, depth)

Search for documents corresponding a condition. `cond’ specifies a condition object. `depth’ specifies the depth of meta search. The return value is a node result object. On error, `nil’ is returned.

set_auth(name, password)

Set the authentication information. `name’ specifies the name of authentication. `passwd’ specifies the password of the authentication. The return value is always `nil’.

set_link(url, label, credit)

Manage a link of a node. `url’ specifies the URL of the target node of a link. `label’ specifies the label of the link. `credit’ specifies the credit of the link. If it is negative, the link is removed. The return value is true if success, else it is false.

set_proxy(host, port)

Set the proxy information. `host’ specifies the host name of a proxy server. `port’ specifies the port number of the proxy server. The return value is always `nil’.

set_snippet_width(wwidth, hwidth, awidth)

Set width of snippet in the result. `wwidth’ specifies whole width of a snippet. By default, it is 480. If it is 0, no snippet is sent. If it is negative, whole body text is sent instead of snippet. `hwidth’ specifies width of strings picked up from the beginning of the text. By default, it is 96. If it is negative 0, the current setting is not changed. `awidth’ specifies width of strings picked up around each highlighted word. By default, it is 96. If it is negative, the current setting is not changed.

set_timeout(sec)

Set timeout of a connection. `sec’ specifies timeout of the connection in seconds. The return value is always `nil’.

set_url(url)

Set the URL of a node server. `url’ specifies the URL of a node. The return value is always `nil’.

set_user(name, mode)

Manage a user account of a node. `name’ specifies the name of a user. `mode’ specifies the operation mode. 0 means to delete the account. 1 means to set the account as an administrator. 2 means to set the account as a guest. The return value is true if success, else it is false.

size()

Get the size of the datbase. The return value is the size of the datbase. On error, -1.0 is returned.

status()

Get the status code of the last request. The return value is the status code of the last request. -1 means failure of connection.

sync()

Synchronize updating contents of the database. The return value is true if success, else it is false.

uri_to_id(uri)

Get the ID of a document specified by URI. `uri’ specifies the URI of a registered document. The return value is the ID of the document. On error, -1 is returned.

users()

Get an array of names of users. The return value is an array object of names of users. On error, `nil’ is returned.

word_num()

Get the number of unique words. The return value is the number of unique words. On error, -1 is returned.

[Validate]