Ruby - リンクチェック - output.rb 結果の出力

クラウディア 
1. 結果の出力

1. 結果の出力

 結果を出力するモジュールです。
#!/usr/bin/env ruby
=begin

結果の出力を行う

=end

require('pry')
require('openssl')
require('readconf')
require('checkparent')
require('outputhtml')

class Output
  def initialize()
  end

  def execute(starttime, finishtime, checked)
    begin
      puts("")
      print('開始 '+sprintf("%04d年%d月%d日 %02d:%02d:%02d", starttime.year, starttime.mon, starttime.day, starttime.hour, starttime.min, starttime.sec))
      puts(' 終了 '+sprintf("%04d年%d月%d日 %02d:%02d:%02d", finishtime.year, finishtime.mon, finishtime.day, finishtime.hour, finishtime.min, finishtime.sec))

      sec = (finishtime-starttime).to_i
      min = sec / 60
      sec = sec % 60

      puts('処理時間 '+sprintf("%02d", min)+'分 '+sprintf("%02d", sec)+'秒')
      puts("")
      puts("#{checked.count} URI")
      puts("")

#      $selfref.each do | value |
#        puts("自己参照 #{value}")
#      end

      puts("")

      $result.each do | key, value |
        if ((value[:結果] != 'OK')         &&
            (value[:結果] != '未チェック') &&
            (value[:結果] != 'nocheck'))
          puts("#{value[:リンク元]}")
          puts("   → #{value[:リンク]} [#{value[:結果]}]")
        end
      end

      puts("")

      if ($output.has_key?('html'))                   # html への出力あり
        File.open($output['html'], "w") do | file |
          outputhtml = OutputHTML.new
          outputhtml.execute(starttime, finishtime, checked, file)
        end
      end
    rescue => error
      exeptlog = ExceptLog.new
      binding.pry
      exeptlog.execute(self, error)
      exit 1
    end
  end
end