Class: MotoRecall::Client::Isuzu
Class Method Summary
collapse
Instance Method Summary
collapse
#find, #initialize, #url
Class Method Details
.url(vin = nil) ⇒ Object
3
4
5
|
# File 'lib/moto_recall/client/isuzu.rb', line 3
def self.url(vin = nil)
"http://www.isuzu.com/index.jsp"
end
|
Instance Method Details
#fetch(vin) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/moto_recall/client/isuzu.rb', line 7
def fetch(vin)
agent = Mechanize.new
agent.user_agent_alias = "Windows Chrome"
response = agent.post(url, {
"vin" => vin
})
response.body
end
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/moto_recall/client/isuzu.rb', line 37
def format(recall)
{
type: nil,
nhtsa_number: recall[:nhtsa_number],
oem_number: recall[:oem_number],
date: nil,
title: nil,
description: recall[:description],
safety_risk: nil,
remedy: nil,
status: recall[:status],
notes: nil
}
end
|
#process(response) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/moto_recall/client/isuzu.rb', line 18
def process(response)
doc = Nokogiri::HTML(response)
table = doc.css("#form table table")
if table.empty?
[]
else
table.css("tr").drop(1).reduce([]) do |memo, row|
cells = row.css("td")
memo << {
oem_number: cells[0].text,
description: cells[1].text,
nhtsa_number: cells[2].text,
status: cells[3].text
}
memo
end
end
end
|