Last active
May 16, 2016 19:46
-
-
Save xdougx/801357ab0f24aef77481dd941f0c7986 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Import | |
class Base | |
attr_accessor :type, :path, :file, :file_type | |
def initialize(params) | |
self.type = params[:type] | |
self.file = params[:file] | |
self.file_type = params[:file_type] | |
self.path = File.join(Rails.root, "public", self.file.original_filename) | |
end | |
def start | |
create | |
run | |
destroy | |
self | |
end | |
private | |
def create | |
File.open path, "wb" do |file| | |
file.write(self.file.read) | |
end | |
end | |
def run | |
# rola o import aqui | |
end | |
def destroy | |
system 'rm', path | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment