Sha256: ffb2e31a5ccbb50b645a489d7527c4c1a6d77d47a8b192f8f2e35ef1a093c16a
Contents?: true
Size: 833 Bytes
Versions: 2
Compression:
Stored size: 833 Bytes
Contents
require 'faraday' require 'nokogiri' module TakuhaiStatus class KuronekoYamato attr_reader :key, :time, :state def initialize(key) @key = key.gsub(/[^0-9]/, '') @time, @state = check end def finish? return !!(@state =~ /^(お客様引渡|配達|投函)完了|返品|国内到着/) end private def check conn = Faraday.new(url: 'http://toi.kuronekoyamato.co.jp/') res = conn.post('/cgi-bin/tneko', {number00: '1', number01: @key}) doc = Nokogiri(res.body) begin tr = doc.css('.meisai')[0].css('tr').last state = tr.css('td')[1].text sday = tr.css('td')[2].text stime = tr.css('td')[3].text time = Time.parse("#{sday} #{stime}") return time, state rescue NoMethodError raise NotMyKey rescue ArgumentError return Time.now, state || '' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
takuhai_status-1.5.5 | lib/takuhai_status/kuronekoyamato.rb |
takuhai_status-1.5.4 | lib/takuhai_status/kuronekoyamato.rb |