lib/takuhai_status/ups.rb in takuhai_status-1.3.1 vs lib/takuhai_status/ups.rb in takuhai_status-1.3.2
- old
+ new
@@ -22,10 +22,14 @@
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\d\/\d\d \d{1,2}:\d\d/)[0]}+0500)"
+ begin
+ time = "#{doc.css('.secHead ul li')[0].text.match(/\d{4}\/\d\d\/\d\d \d{1,2}:\d\d/)[0]}+0500)"
+ rescue NoMethodError
+ time = "#{doc.css('.secHead ul li')[0].text.match(/\d{4}\/\d\d\/\d\d/)[0]} 00:00:00+0500)"
+ end
return Time.parse(time).localtime, state
rescue NoMethodError
raise NotMyKey
rescue ArgumentError
return Time.now, ''