Class: Sunnyside::SunnyFTP
- Inherits:
-
Object
- Object
- Sunnyside::SunnyFTP
- Defined in:
- lib/sunnyside/ftp.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#ftp ⇒ Object
readonly
Returns the value of attribute ftp.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #check_for_new_files ⇒ Object
-
#initialize(login = {}) ⇒ SunnyFTP
constructor
A new instance of SunnyFTP.
- #log_on ⇒ Object
- #new_files ⇒ Object
Constructor Details
#initialize(login = {}) ⇒ SunnyFTP
Returns a new instance of SunnyFTP.
17 18 19 20 21 22 |
# File 'lib/sunnyside/ftp.rb', line 17 def initialize(login = {}) @ftp = Net::FTP.new(login[:site]) @username = login[:username] @password = login[:password] @name = login[:provider] end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
15 16 17 |
# File 'lib/sunnyside/ftp.rb', line 15 def directory @directory end |
#ftp ⇒ Object (readonly)
Returns the value of attribute ftp.
15 16 17 |
# File 'lib/sunnyside/ftp.rb', line 15 def ftp @ftp end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/sunnyside/ftp.rb', line 15 def name @name end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
15 16 17 |
# File 'lib/sunnyside/ftp.rb', line 15 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
15 16 17 |
# File 'lib/sunnyside/ftp.rb', line 15 def username @username end |
Instance Method Details
#check_for_new_files ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sunnyside/ftp.rb', line 28 def check_for_new_files ftp.chdir("../outgoing") incoming = IncomingFiles.new(ftp, name) incoming.download_files ftp.chdir("../incoming") outgoing = OutgoingFiles.new(ftp, name) outgoing.upload_files puts "Exiting #{name}..." ftp.close end |
#log_on ⇒ Object
24 25 26 |
# File 'lib/sunnyside/ftp.rb', line 24 def log_on ftp.login(username, password) end |
#new_files ⇒ Object
42 43 44 |
# File 'lib/sunnyside/ftp.rb', line 42 def new_files files.map { |file| (file) + "-#{file}" }.select { |file| provider_folder.include?((file)) }.size > 0 end |