Sha256: 8777def9617b4e461922323ef3f972ec7a5345c64fe70a286f0bd5aa3990c60c

Contents?: true

Size: 655 Bytes

Versions: 5

Compression:

Stored size: 655 Bytes

Contents

require "simple2ch/version"

module Simple2ch
  DEBUG = false

  require 'simple2ch/simple2ch_exception'
  require 'simple2ch/board'
  require 'simple2ch/dat'
  require 'simple2ch/res'
  require 'simple2ch/thre'
  require 'net/http'
  require 'time'
  require 'charwidth'
  require 'pp' if DEBUG

  def self.root
    File.dirname __dir__
  end

  # HTTPでGETする
  # @param [URI] url URL
  # @return [String] 取得本文
  def self.fetch(url)
    req = Net::HTTP::Get.new(url.path)
    res = Net::HTTP.start(url.host, url.port) {|http|
      http.request(req)
    }
    res.body.force_encoding("cp932").encode!('utf-8', :undef => :replace)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple2ch-0.1.5 lib/simple2ch.rb
simple2ch-0.1.4 lib/simple2ch.rb
simple2ch-0.1.3 lib/simple2ch.rb
simple2ch-0.1.2 lib/simple2ch.rb
simple2ch-0.1.1 lib/simple2ch.rb