The base class for all SFTP operations. Subclasses must implement a perform method, which accepts the arguments expected by the corresponding method of the driver. Subclasses may also override the default implementations of do_status, do_data, do_name, do_handle, and do_attrs, as necessary.

Methods
Included Modules
Constants
Status = Struct.new( :code, :message, :language )
  A structure for reporting status information.
OK = Status.new( FX_OK, "Success", "" )
  A constant for representing the commonly-used FX_OK status.
Public Class methods
new( log, session, driver )

Create a new operation with the given logger instance, which will operate atop the given session, using the given driver to format and send the requests to the server.

    # File lib/net/sftp/operations/abstract.rb, line 38
38:     def initialize( log, session, driver )
39:       @log = log
40:       @session = session
41:       @driver = driver
42:     end
Public Instance methods
do_attrs( attributes )

A callback for SFTP attrs packets. By default, invokes the registered callback, passing an OK status and the attributes object.

     # File lib/net/sftp/operations/abstract.rb, line 102
102:     def do_attrs( attributes )
103:       @callback[ OK, attributes ]
104:     end
do_data( data )

A callback for SFTP data packets. By default, invokes the registered callback, passing an OK status and the data.

    # File lib/net/sftp/operations/abstract.rb, line 90
90:     def do_data( data )
91:       @callback[ OK, data ]
92:     end
do_handle( handle )

A callback for SFTP handle packets. By default, invokes the registered callback, passing an OK status and the handle.

    # File lib/net/sftp/operations/abstract.rb, line 84
84:     def do_handle( handle )
85:       @callback[ OK, handle ]
86:     end
do_name( items )

A callback for SFTP name packets. By default, invokes the registered callback, passing an OK status and the list of items.

    # File lib/net/sftp/operations/abstract.rb, line 96
96:     def do_name( items )
97:       @callback[ OK, items ]
98:     end
do_status( code, message, language )

A callback for SFTP status packets. By default, raises an exception unless the status is FX_OK, in which case the registered callback is invoked.

    # File lib/net/sftp/operations/abstract.rb, line 77
77:     def do_status( code, message, language )
78:       raise StatusException.new( code, message, language ) unless code == FX_OK
79:       @callback[ Status.new( code, message, language ) ]
80:     end
execute( *args, &callback )

Execute the operation. If a callback is given, the operation will be performed asynchronously with the callback being invoked when the operation completes. If a callback is not given, the operation will be performed synchronously, with the expected value being returned.

    # File lib/net/sftp/operations/abstract.rb, line 48
48:     def execute( *args, &callback )
49:       @log.debug "executing" if @log.debug?
50: 
51:       unless block_given?
52:         status = result = nil
53:         callback = Proc.new do |status, *pargs|
54:           status = status
55:           result = case
56:             when pargs.empty? then @session.status
57:             when pargs.length == 1 then pargs.first
58:             else pargs
59:           end
60:         end
61:       end
62: 
63:       @callback = callback
64:       @id = perform *args
65:       @log.debug "received request id #{@id}"
66:       @session.register( @id, self )
67: 
68:       unless block_given?
69:         @session.loop { status.nil? }
70:         @session.status = status
71:         return result
72:       end
73:     end