Class: Gared::Hebrewbooks

Inherits:
Object
  • Object
show all
Defined in:
lib/gared/hebrewbooks.rb

Instance Method Summary collapse

Constructor Details

#initializeHebrewbooks

Returns a new instance of Hebrewbooks.



5
6
7
# File 'lib/gared/hebrewbooks.rb', line 5

def initialize
  @browser = Watir::Browser.new :chrome, options: {args: ['--no-sandbox', '--headless']}
end

Instance Method Details

#query_person(person) ⇒ Object



12
13
# File 'lib/gared/hebrewbooks.rb', line 12

def query_person(person)
end

#query_persons(q) ⇒ Object



9
10
# File 'lib/gared/hebrewbooks.rb', line 9

def query_persons(q)
end

#query_publication(publication) ⇒ Object



18
19
# File 'lib/gared/hebrewbooks.rb', line 18

def query_publication(publication)
end

#query_publications(q) ⇒ Object



15
16
# File 'lib/gared/hebrewbooks.rb', line 15

def query_publications(q)
end

#query_publications_by_person(person, ctx = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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