How do I use this Ruby code? -


I have been able to use the Imagehack API on CodeSnippets. I'm new to Ruby on Rails, so I know how to use models, views and controllers in general, but I'm not sure how to use this code. Will this be a module? Thanks for reading.

Returns direct link to imacsac. 'RabbiGums' is required 'HPricot' is required 'Net / HT' is required 'Yuri' is required 'CGI' is required 'mime / type' category. ShackMirror SHACK_ID = "Change your picture ID with you" USER_AGENT = "Mozilla / 5.0 (MacItosh; U. Intel Mac OS X; N) Apple WebKat / 41 9 (Like KHTML) Safari / 41 9.3" Bandary = '- -------- Pushar Indabass H_ $$ 'Attr_reader: url def initialization (img) to non-image type error,' expected image file. 'Until IMG = ~ / JP? G. PNG | GIF | BMP | TIF | TIF | STF $ / @ IMG = IMG @ Aral, @ Hoster, @RR = "", "", "@header, @ palus = {}, {} @homester ['cookie'] =" mimeage = # {SHACK_ID} "@head ['user-agent'] = USER_AGENT @ ultimate ['uploadtype'] = 'at' '[' brand '] =' 'absolute [[reference'] = '' '@ param [' MAX_FILE_SIZE '] =' '13145728' @ Param ['Optimization'] = '0' @ Ultimate ['Ribb'] = '1' transfer getdirect end secure def Prepare_multipart (params) fp = [] params.each do | K, v | If v.ed_to? (Read: fp.push file param.New (k, vp, v.read)) FP pius (Ultimate new (K, V)) End Closing Query = FP collect {| P | "- + + BOUNDARY +" \ r \ n "+ p.to_multipart} .Join (" ") +" - "+ BOUNDARY +" - "return query fdf prepfile (path_to_file) file = File.new (Path_to_file) @ Header ['content type'] = "multipart / form-data, limit =" + BOUNDARY + "" @user ['url'] = 'paste image URL' 'absolute [' file upload '] = file $ query = ready_multipart (@love) file.close end df search (path) path! ~ / ^ Http /? "Local": Perform "Remote" End Diff Upload (Query, Header = {}) Net :: HTTP.start (@ hosturi.host). Http Http.post (@ hosturi.path, query, header); End and Def Transload (url) @header ['content-type'] = 'form-data' @ param ['url'] = url @ param ['fileupload'] = '' posterac = net :: http :: post .new (@ hosturi.path, @header) postreq.set_form_data (@love) Return Net :: HTTP.new (@ hosturi.host, @ hosturi.port) .start {| Http | Http.request (postreq)} Locate the End Deaf Transfer Case (@img) when "local" @ hostlue = URI. PRS ('http://load.imageshack.us/index.php') prepFile (@img) @res = upload ($ query, @ header) when "Remote" @ Hoster = URI.pros ('http: // Imageshack.us/transload.php ') @res = transload (@img) end end def getdirect doctor = hpricot (@ res.body) @url = (doc / "// input"). The last ['value'] end-end class para attractor: k, v def initialize (k, v) @k = k @v = v end def to_multipart return "content-presentation: form-data; name = \" # { CGI :: Escape (K)} \ "\ r \ n \ r \ n # {v} \ r \ n" End and Class Foundam Atre_Aksair: K ,: File Name: Content Def Initial (k, file name, content) @ K = k @filename = filename @content = content end def to_multipart return "content-presentation: form-data; name = \" # {CGI:: escape (k)} \ "; filename = \" # {filename} \ "\ R \ n" + "Content-Type: # {MIME :: Type Type_ (@filename)} \ r \ n \ r \ n "+ content +" \ r \ n "end and end

This is not a helpful file, it is a library file. Therefore, if you want to use it, you can leave it only in Lib folder


Comments