Class: Sunnyside::OutgoingFiles
- Defined in:
- lib/sunnyside/ftp.rb
Instance Attribute Summary collapse
-
#ftp ⇒ Object
readonly
Returns the value of attribute ftp.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from SunnyFTP
#directory, #password, #username
Instance Method Summary collapse
-
#initialize(ftp, name) ⇒ OutgoingFiles
constructor
A new instance of OutgoingFiles.
- #new_files ⇒ Object
- #upload_file(file) ⇒ Object
- #upload_files ⇒ Object
Methods inherited from SunnyFTP
Constructor Details
#initialize(ftp, name) ⇒ OutgoingFiles
Returns a new instance of OutgoingFiles.
82 83 84 85 |
# File 'lib/sunnyside/ftp.rb', line 82 def initialize(ftp, name) @name = name @ftp = ftp end |
Instance Attribute Details
#ftp ⇒ Object (readonly)
Returns the value of attribute ftp.
80 81 82 |
# File 'lib/sunnyside/ftp.rb', line 80 def ftp @ftp end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
80 81 82 |
# File 'lib/sunnyside/ftp.rb', line 80 def name @name end |
Instance Method Details
#new_files ⇒ Object
87 88 89 |
# File 'lib/sunnyside/ftp.rb', line 87 def new_files Dir["#{DRIVE}/sunnyside-files/ftp/837/#{name}/*.txt"] end |
#upload_file(file) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/sunnyside/ftp.rb', line 99 def upload_file(file) ftp.putbinaryfile(file) puts "#{file} uploaded." puts "Deleting local file..." File.delete(file) puts "File deleted." end |
#upload_files ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/sunnyside/ftp.rb', line 91 def upload_files if new_files.size > 0 new_files.each { |file| upload_file(file) } else puts "No new files to upload." end end |