Class: Alexandria::BookProviders::Z3950Provider
- Inherits:
-
AbstractProvider
- Object
- AbstractProvider
- Alexandria::BookProviders::Z3950Provider
- Includes:
- Logging, GetText
- Defined in:
- lib/alexandria/book_providers/z3950_provider.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from AbstractProvider
Instance Method Summary collapse
- #books_from_resultset(resultset, isbn) ⇒ Object
-
#initialize(name = "Z3950", fullname = "Z39.50") ⇒ Z3950Provider
constructor
A new instance of Z3950Provider.
- #search(criterion, type) ⇒ Object
- #url(_book) ⇒ Object
Methods included from Logging
Methods inherited from AbstractProvider
#<=>, #abstract?, abstract?, #action_name, #enabled, #reinitialize, #remove, #toggle_enabled, #transport, unabstract, #variable_name
Constructor Details
#initialize(name = "Z3950", fullname = "Z39.50") ⇒ Z3950Provider
Returns a new instance of Z3950Provider.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/alexandria/book_providers/z3950_provider.rb', line 18 def initialize(name = "Z3950", fullname = "Z39.50") super prefs.add("hostname", _("Hostname"), "") prefs.add("port", _("Port"), 7090) prefs.add("database", _("Database"), "") prefs.add("record_syntax", _("Record syntax"), "USMARC", ["USMARC", "UNIMARC", "SUTRS"]) prefs.add("username", _("Username"), "", nil, false) prefs.add("password", _("Password"), "", nil, false) prefs.add("charset", _("Charset encoding"), "ISO-8859-1") # HACK : piggybacking support prefs.add("piggyback", "Piggyback", true, [true, false]) prefs.read end |
Instance Method Details
#books_from_resultset(resultset, isbn) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/alexandria/book_providers/z3950_provider.rb', line 54 def books_from_resultset(resultset, isbn) case prefs["record_syntax"] when /MARC$/ books_from_marc(resultset, isbn) when "SUTRS" books_from_sutrs(resultset) else raise NoResultsError end end |
#search(criterion, type) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/alexandria/book_providers/z3950_provider.rb', line 34 def search(criterion, type) prefs.read criterion = criterion.encode(prefs["charset"]) isbn = type == SEARCH_BY_ISBN ? criterion : nil criterion = canonicalise_criterion(criterion, type) conn_count = request_count(type) resultset = search_records(criterion, type, conn_count) log.debug { "total #{resultset.length}" } results = books_from_resultset(resultset, isbn) raise NoResultsError if results.empty? type == SEARCH_BY_ISBN ? results.first : results end |
#url(_book) ⇒ Object
50 51 52 |
# File 'lib/alexandria/book_providers/z3950_provider.rb', line 50 def url(_book) nil end |