class Gared::Hebrewbooks

Public Class Methods

new() click to toggle source
# File lib/gared/hebrewbooks.rb, line 5
def initialize
  @browser = Watir::Browser.new :chrome, options: {args: ['--no-sandbox', '--headless']}
end

Public Instance Methods

query_person(person) click to toggle source
# File lib/gared/hebrewbooks.rb, line 12
def query_person(person)
end
query_persons(q) click to toggle source
# File lib/gared/hebrewbooks.rb, line 9
def query_persons(q)
end
query_publication(publication) click to toggle source
# File lib/gared/hebrewbooks.rb, line 18
def query_publication(publication)
end
query_publications(q) click to toggle source
# File lib/gared/hebrewbooks.rb, line 15
def query_publications(q)
end
query_publications_by_person(person, ctx = nil) click to toggle source
# File lib/gared/hebrewbooks.rb, line 21
def query_publications_by_person(person, ctx = nil)
  @browser.goto 'http://hebrewbooks.org/home.aspx'
  @browser.wait
  t = @browser.text_field(id: 'cpMstr_author')
  t.set(person)
  @browser.form(id: 'form1').submit # get publications by person
  @browser.wait
  trs = @browser.div(id: 'dbresults').trs
  ret = []
  if trs.size > 0
    trs.each do |tr|
      p = Publication.new(ctx)
      p.title = tr.tds[0].text
      p.author_line = tr.tds[1].text
      p.source_id = tr.tds[0].a.href
      p.scanned = true
      h = Holding.new
      h.source_id = tr.tds[0].a.href
      h.source_name = 'Hebrewbooks'
      h.scan_url = "http://download.hebrewbooks.org/downloadhandler.ashx?req=#{h.source_id.rpartition('=')[2]}"
      p.add_holding(h)
      ret << p
    end
  end
  return ret
  # TODO: support multiple result pages
end