Class: WarrantyCheck::HP

Inherits:
BaseVendor show all
Defined in:
lib/vendors/hp_vendor.rb

Instance Attribute Summary

Attributes inherited from BaseVendor

#dom, #html, #warranties

Instance Method Summary collapse

Methods inherited from BaseVendor

#http_method, #initialize, #uri, #url

Constructor Details

This class inherits a constructor from WarrantyCheck::BaseVendor

Instance Method Details

#checkObject



13
14
15
16
17
18
19
20
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
48
49
50
51
# File 'lib/vendors/hp_vendor.rb', line 13

def check
  @warranties = []

  table = dom.search("td td table:nth-child(3)")      
  table.search("tr")[1..-1].to_a.each do |elem|
    tds = elem.search("td")
    
    next if !(6..7).include?(tds.count)
    
    @warranty_type ||= (tds.size == 7 ? tds[0].text.strip : nil)
    n = (tds.size == 7 ? 0 : -1)

    details_warranty_type = @warranty_type
    details_service_type  = tds[n+1].text.strip
    details_start_date    = Time.strptime(tds[n+2].text.strip, "%d %b %Y")
    details_end_date      = Time.strptime(tds[n+3].text.strip, "%d %b %Y")
    details_status        = tds[n+4].text.strip
    details_service_level = tds[n+5].text.strip
    details_deliverables  = tds[n+6].text.strip
    
    warranty = {
      :description => "#{details_warranty_type} - #{details_service_type}",
      :expired => (details_status == "Expired" ? true : false),
      :expire_date => details_end_date,
      
      :details => {
        :warranty_type => details_warranty_type,
        :service_type  => details_service_type ,
        :start_date    => details_start_date   ,
        :end_date      => details_end_date     ,
        :status        => details_status       ,
        :service_level => details_service_level,
        :deliverables  => details_deliverables ,
      }
    }

    @warranties << warranty
  end
end

#service_base_urlObject



5
6
7
# File 'lib/vendors/hp_vendor.rb', line 5

def service_base_url
  "http://h20000.www2.hp.com"
end

#service_uriObject



9
10
11
# File 'lib/vendors/hp_vendor.rb', line 9

def service_uri
  "/bizsupport/TechSupport/WarrantyResults.jsp?nickname=&sn=%s&pn=&country=CA&lang=en&cc=us"
end