class Alexandria::BookProviders::SBNProvider

Public Class Methods

new() click to toggle source
# File lib/alexandria/book_providers/z3950.rb, line 319
def initialize
  super("SBN", "Servizio Bibliotecario Nazionale (Italy)")
  prefs.variable_named("hostname").default_value = "opac.sbn.it"
  prefs.variable_named("port").default_value = 3950
  prefs.variable_named("database").default_value = "nopac"
  # supported 'USMARC', 'UNIMARC' , 'SUTRS'
  prefs.variable_named("record_syntax").default_value = "USMARC"
  prefs.variable_named("charset").default_value = "ISO-8859-1"
  prefs.read
end

Public Instance Methods

url(book) click to toggle source
# File lib/alexandria/book_providers/z3950.rb, line 330
def url(book)
  "http://sbnonline.sbn.it/cgi-bin/zgw/BRIEF.pl?displayquery=" \
    "%253CB%253E%253Cfont%2520color%253D%2523000064%253E" \
    "Codice%2520ISBN%253C%2FB%253E%253C%2Ffont%253E%2520" \
    "contiene%2520%2522%2520%253CFONT%2520COLOR%253Dred%253E" +
    canonicalise_isbn_with_dashes(book.isbn) +
    "%253C%2FFONT%253E%2522&session=&zurl=opac" \
    "&zquery=%281%3D7+4%3D2+2%3D3+5%3D100+6%3D1+3%3D3+%22" +
    canonicalise_isbn_with_dashes(book.isbn) +
    "%22%29&language=it&maxentries=10&target=0&position=1"
rescue StandardError => ex
  log.warn { "Cannot create url for book #{book}; #{ex.message}" }
  nil
end

Private Instance Methods

canonicalise_criterion(criterion, _type) click to toggle source
# File lib/alexandria/book_providers/z3950.rb, line 347
def canonicalise_criterion(criterion, _type)
  canonicalise_isbn_with_dashes(criterion)
end
canonicalise_isbn_with_dashes(isbn) click to toggle source
# File lib/alexandria/book_providers/z3950.rb, line 355
def canonicalise_isbn_with_dashes(isbn)
  # The reference for the position of the dashes is
  # http://www.isbn-international.org/converter/ranges.htm

  isbn = Alexandria::Library.canonicalise_isbn(isbn)

  if isbn[0..1] == "88"
    # Italian speaking area
    if isbn > "8895000" && (isbn <= "8899999996")
      isbn[0..1] + "-" + isbn[2..6] + "-" + isbn[7..8] + "-" + isbn[9..9]
    elsif isbn > "88900000"
      isbn[0..1] + "-" + isbn[2..7] + "-" + isbn[8..8] + "-" + isbn[9..9]
    elsif isbn > "8885000"
      isbn[0..1] + "-" + isbn[2..6] + "-" + isbn[7..8] + "-" + isbn[9..9]
    elsif isbn > "886000"
      isbn[0..1] + "-" + isbn[2..5] + "-" + isbn[6..8] + "-" + isbn[9..9]
    elsif isbn > "88200"
      isbn[0..1] + "-" + isbn[2..4] + "-" + isbn[5..8] + "-" + isbn[9..9]
    elsif isbn > "8800"
      isbn[0..1] + "-" + isbn[2..3] + "-" + isbn[4..8] + "-" + isbn[9..9]
    else
      raise _("Invalid ISBN")
    end

  else
    isbn
  end
end
request_count(_type) click to toggle source
# File lib/alexandria/book_providers/z3950.rb, line 351
def request_count(_type)
  0
end