All pastes #336760 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-02 07:19 UTC
rendered paste body
#!/usr/bin/ruby

require 'rubygems'
require 'net/http'
require 'hpricot'

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

    def getCode
        @code = File.read(@file)
    end

    def sendCode
        data = {"content" => @code, "description" => nil, "type" => '1', "expiry" => nil,
        "name" => nil, "s" => 'Submit+Post' }
        @response = Net::HTTP.post_form(URI.parse('http://pastebin.ca/new.php'), data)
    end

    def getLink
        puts @response
    end
end

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