Class: BillHicks::FTP
- Inherits:
-
Object
- Object
- BillHicks::FTP
- Defined in:
- lib/bill_hicks/ftp.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(credentials) ⇒ FTP
constructor
A new instance of FTP.
- #login(username, password) ⇒ Object
Constructor Details
#initialize(credentials) ⇒ FTP
Returns a new instance of FTP.
6 7 8 9 10 |
# File 'lib/bill_hicks/ftp.rb', line 6 def initialize(credentials) @connection ||= Net::FTP.new(BillHicks.config.ftp_host) @connection.passive = true self.login(credentials[:username], credentials[:password]) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/bill_hicks/ftp.rb', line 4 def connection @connection end |
Instance Method Details
#close ⇒ Object
18 19 20 |
# File 'lib/bill_hicks/ftp.rb', line 18 def close @connection.close end |
#login(username, password) ⇒ Object
12 13 14 15 16 |
# File 'lib/bill_hicks/ftp.rb', line 12 def login(username, password) @connection.login(username, password) rescue Net::FTPPermError raise BillHicks::NotAuthenticated end |