Class: Stockboy::Providers::FTP::FTPAdapter
- Inherits:
-
Object
- Object
- Stockboy::Providers::FTP::FTPAdapter
- Defined in:
- lib/stockboy/providers/ftp/ftp_adapter.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #chdir(directory) ⇒ Object
- #delete(file_name) ⇒ Object
- #download(file_name) ⇒ Object
-
#initialize(provider) ⇒ FTPAdapter
constructor
A new instance of FTPAdapter.
- #list_files ⇒ Object
- #modification_time(file_name) ⇒ Object
- #open ⇒ Object
- #size(file_name) ⇒ Object
Constructor Details
#initialize(provider) ⇒ FTPAdapter
Returns a new instance of FTPAdapter.
7 8 9 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 7 def initialize(provider) @provider = provider end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 5 def client @client end |
Class Method Details
.exception_class ⇒ Object
46 47 48 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 46 def self.exception_class Net::FTPError end |
Instance Method Details
#chdir(directory) ⇒ Object
22 23 24 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 22 def chdir(directory) client.chdir directory end |
#delete(file_name) ⇒ Object
30 31 32 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 30 def delete(file_name) client.delete file_name end |
#download(file_name) ⇒ Object
34 35 36 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 34 def download(file_name) client.get(file_name, nil) end |
#list_files ⇒ Object
26 27 28 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 26 def list_files client.nlst.sort end |
#modification_time(file_name) ⇒ Object
38 39 40 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 38 def modification_time(file_name) client.mtime file_name end |
#open ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 11 def open result = nil Net::FTP.open(@provider.host, @provider.username, @provider.password) do |ftp| @client = ftp client.binary = @provider.binary client.passive = @provider.passive result = yield self end result end |
#size(file_name) ⇒ Object
42 43 44 |
# File 'lib/stockboy/providers/ftp/ftp_adapter.rb', line 42 def size(file_name) client.size file_name end |