Class: XFTP::Operations::FTP::Glob Private

Inherits:
Object
  • Object
show all
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.

Note:

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

See Also:

  • Net::FTP#nslt

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

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

Parameters:

  • pattern (String)

    the search pattern

  • callback (Proc)


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