Class: DeliveryStateJp::Yamato
- Inherits:
-
Base
- Object
- Base
- DeliveryStateJp::Yamato
show all
- Defined in:
- lib/delivery_state_jp/yamato.rb
Class Method Summary
collapse
Methods inherited from Base
response_body, tracking_error_message
Class Method Details
.action_url ⇒ Object
14
15
16
|
# File 'lib/delivery_state_jp/yamato.rb', line 14
def self.action_url
'http://toi.kuronekoyamato.co.jp/cgi-bin/tneko'
end
|
.charset ⇒ Object
26
27
28
|
# File 'lib/delivery_state_jp/yamato.rb', line 26
def self.charset
'shift-jis'
end
|
.delivery_state(args) ⇒ Object
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/delivery_state_jp/yamato.rb', line 3
def self.delivery_state(args)
doc = Nokogiri::HTML.parse(response_body(args).force_encoding("UTF-8"), nil, charset)
content = doc.xpath('/html/body/p/script[4]').first.content
if m = content.match(/1件目.+\n.+.+\n.+\n.+swd.write.+>(?<state>.+)\<br\>\<\/font\>\<\/td\>/)
m[:state]
else
'不明'
end
end
|
.error_messages ⇒ Object
30
31
32
|
# File 'lib/delivery_state_jp/yamato.rb', line 30
def self.error_messages
%w(伝票番号誤り)
end
|
.post_params(number) ⇒ Object
18
19
20
|
# File 'lib/delivery_state_jp/yamato.rb', line 18
def self.post_params(number)
{'number01' => number, 'number00' => '1'}
end
|
.xpath(index) ⇒ Object
22
23
24
|
# File 'lib/delivery_state_jp/yamato.rb', line 22
def self.xpath(index)
"/html/body/center[1]/form/table/tr[#{index+2}]/td[5]/font/text()"
end
|