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
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.
Included Modules
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 97
97:     def do_attrs( attributes )
98:       @callback[ OK, attributes ]
99:     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 85
85:     def do_data( data )
86:       @callback[ OK, data ]
87:     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 79
79:     def do_handle( handle )
80:       @callback[ OK, handle ]
81:     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 91
91:     def do_name( items )
92:       @callback[ OK, items ]
93:     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 72
72:     def do_status( code, message, language )
73:       raise StatusException.new( code, message, language ) unless code == FX_OK
74:       @callback[ Status.new( code, message, language ) ]
75:     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:         callback = Proc.new do |status, *pargs|
53:           @session.status = status
54:           case
55:             when pargs.empty? then return @session.status
56:             when pargs.length == 1 then return pargs.first
57:             else return pargs
58:           end
59:         end
60:       end
61: 
62:       @callback = callback
63:       @id = perform *args
64:       @log.debug "received request id #{@id}"
65:       @session.register( @id, self )
66: 
67:       @session.loop unless block_given?
68:     end