Class: Metakiller

Inherits:
Object
  • Object
show all
Defined in:
lib/metakiller.rb

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Metakiller

Returns a new instance of Metakiller.



9
10
11
12
# File 'lib/metakiller.rb', line 9

def initialize(token)
	@token = token
	@url = URI.parse("http://192.168.1.137:3000/#{@token}/clean")
end

Instance Method Details

#clean(filepath) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/metakiller.rb', line 14

def clean(filepath)
  File.open(filepath) do |file|
 req = Net::HTTP::Post::Multipart.new @url.path,
   "files[]" => UploadIO.new(file, getMime(filepath), File.basename(filepath))
 res = Net::HTTP.start(@url.host, @url.port) do |http|
   http.request(req)
	  end
	  return res.body
	end
end

#getMime(filepath) ⇒ Object



25
26
27
# File 'lib/metakiller.rb', line 25

def getMime(filepath)
	return MimeMagic.by_magic(File.open(filepath))
end