Class: RbEAI::GetFtpLogic
- Inherits:
-
Object
- Object
- RbEAI::GetFtpLogic
- Defined in:
- lib/rbeai/GetLogic.rb
Instance Method Summary collapse
- #getFiles ⇒ Object
-
#initialize(protNode, task) ⇒ GetFtpLogic
constructor
A new instance of GetFtpLogic.
Constructor Details
#initialize(protNode, task) ⇒ GetFtpLogic
Returns a new instance of GetFtpLogic.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rbeai/GetLogic.rb', line 53 def initialize(protNode, task) @task = task location = XPath.first(protNode, "./location") account = XPath.first(protNode, "./account") @address = location.attributes["address"] @port = location.attributes["port"] @folder = location.attributes["folder"] @name = account.attributes["name"] @pwd = account.attributes["pwd"] @pattern = task.pattern end |
Instance Method Details
#getFiles ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rbeai/GetLogic.rb', line 65 def getFiles() begin filesaux = [] Net::FTP.open(@address) do |ftp| ftp.login(@name, @pwd) files = ftp.chdir(@folder) files = ftp.ls("#{@pattern}") re = Regexp.new("#{@pattern}") rio("tmp/#{@task.wflow.instid}/#{@task.name}").mkdir files.each do |file| mr = re.match(file) puts mr remotefilename = mr[0] localfilename = "tmp/#{@task.wflow.instid}/#{@task.name}/#{remotefilename}" puts localfilename ftp.gettextfile(remotefilename, localfilename) filesaux << localfilename end end return filesaux rescue Exception puts $! end end |