class Object

Constants

NONOPASTE

Public Instance Methods

main() click to toggle source
# File nonopaste, line 9
def main
  if $stdin.tty? && !$*.empty? # read data from file
    $*.map{ |file|
      post(open(file).read)
    }
  else # read data from input redirection
    post($stdin.read)
  end
end
post(data, nick=`whoami`.chomp) click to toggle source
# File nonopaste, line 19
def post(data, nick=`whoami`.chomp)
  uri = URI(NONOPASTE)
  Net::HTTP.start(uri.host, uri.port){ |http|
    req = Net::HTTP::Post.new(uri.path)
    req.set_form_data({ :body => data, :nick => nick })
    res = http.request(req)
    loc = res['location']
  }
end