Class: XFTP::Operations::FTP::Glob Private
- Inherits:
-
Object
- Object
- XFTP::Operations::FTP::Glob
- Defined in:
- lib/xftp/operations/ftp/glob.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
It isn’t tested on Windows OS and chances are that it won’t work, that’s why it is implemented as a separate “command”
Provides a naive glob operation implementation, using (see FTP#nlst) method
Constant Summary collapse
- NO_SUCH_FILE_OR_DIRECTORY_CODE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
450
Instance Method Summary collapse
-
#call(pattern, &callback) ⇒ Object
private
Expands pattern and returns the results as matches or as arguments given to the block.
-
#initialize(ftp) ⇒ Glob
constructor
private
A new instance of Glob.
Constructor Details
#initialize(ftp) ⇒ Glob
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Glob.
12 13 14 |
# File 'lib/xftp/operations/ftp/glob.rb', line 12 def initialize(ftp) @ftp = ftp end |
Instance Method Details
#call(pattern, &callback) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Expands pattern and returns the results as matches or as arguments given to the block
20 21 22 23 24 25 |
# File 'lib/xftp/operations/ftp/glob.rb', line 20 def call(pattern, &callback) @ftp.nlst(pattern).each { |filename| callback.call(filename) } rescue Net::FTPTempError => err code = err.to_s[0, 3].try(:to_i) raise err unless code == NO_SUCH_FILE_OR_DIRECTORY_CODE end |