All pastes #332745 Raw Edit

Someone

public text v1 · immutable
#332745 ·published 2007-01-30 07:00 UTC
rendered paste body
#!/usr/bin/ruby

require 'net/http'

class PasteBin
    attr_reader :file
    attr_reader :code
    def initialize(file)
        @file = file
        @code = nil
    end

    def getCode
        File.open(@file, "r") do |file|
            file.each_line { |line| @code = "#@code" + line }
        end
    end

    def sendCode
        Net::HTTP.start('pastebin.ca') do |http|
            @response = http.post("/new.php", "content=#@code&description=&type=1&expiry=&name=&s=Submit+Post")
        end
    end

    def getLink
        puts @response
        #puts(@reaponse.slice(/!\http\:\/\/pastebin\.ca\//))
    end
end

paste = PasteBin.new(ARGV[0])
paste.getCode
paste.sendCode
paste.getLink