Class: HCPL

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/HCPL.rb

Class Method Summary collapse

Class Method Details

.nameObject



28
29
30
# File 'lib/plugins/HCPL.rb', line 28

def self.name
  "Harris County Public Library"
end

.parse(html) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/plugins/HCPL.rb', line 7

def self.parse(html)
  xml = Nokogiri::XML.parse(html)
  results = xml.css(".tableBackground .tableBackground .tableBackground .tableBackground .tableBackground .tableBackground").collect do |table|
    trs = table.css("tr")
    # TODO handle muliple book returns
    # Currently mask multiple books as no results
    # see isbn 0887307280
    if(trs[0].css("td")[0].css("a").text =~ /Location/)
      trs[1, trs.length-1].collect do |tr|
        tds = tr.css("td")
        due_date = ''
        due_date = tds[4].text if tds[4]
        HoustonLibrarySearch::Listing.new(tds[0].text, tds[2].text, tds[3].text, due_date)
      end
    end
  end
  #handle masking
  results = results.select{|x| x}
  results.flatten
end

.url(isbn) ⇒ Object



3
4
5
# File 'lib/plugins/HCPL.rb', line 3

def self.url(isbn)
  "http://catalog.hcpl.net/ipac20/ipac.jsp?index=ISBNEXH&term=#{isbn}"
end