lib/takuhai_status/ups.rb in takuhai_status-1.1.1 vs lib/takuhai_status/ups.rb in takuhai_status-1.1.2
- old
+ new
@@ -9,11 +9,11 @@
@key = key.gsub(/[^a-zA-Z0-9]/, '')
@time, @state = check
end
def finish?
- return !!(@state =~ /配達済み|配達しました/)
+ return !!(@state =~ /配達済み/)
end
private
def check
uri = "http://www.ups.com/WebTracking/processInputRequest?loc=ja_JP&Requester=NES&tracknum=#{@key}"
@@ -22,11 +22,11 @@
html.gsub!(/\u0000/,'')
doc = Nokogiri::HTML.parse(html, uri, "utf-8")
begin
state = doc.css('.newstatus #ttc_tt_spStatus h3')[0].text.strip
- time = "#{doc.css('.secHead ul li')[0].text.match(/\d{4}\/\d{2}\/\d{2} \d{1,2}:\d{2}/)[0]}+5000)"
- return Time.parse(time), state
+ time = "#{doc.css('.secHead ul li')[0].text.match(/\d{4}\/\d\d\/\d\d \d{1,2}:\d\d/)[0]}+0500)"
+ return Time.parse(time).localtime, state
rescue NoMethodError
raise NotMyKey
rescue ArgumentError
return Time.now, ''
end