Class: JschSFTP::SFTP::Session
- Inherits:
-
Object
- Object
- JschSFTP::SFTP::Session
- Defined in:
- lib/jsch_sftp/sftp/session.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Class Method Summary collapse
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #disconnect ⇒ Object
- #download!(remote_filepath, local_filepath) ⇒ Object
- #entries(remote_path) ⇒ Object
-
#initialize(session, channel) ⇒ Session
constructor
A new instance of Session.
- #mkdir(remote_path) ⇒ Object
- #upload!(local_filepath, remote_filepath) ⇒ Object
Constructor Details
#initialize(session, channel) ⇒ Session
Returns a new instance of Session.
8 9 10 |
# File 'lib/jsch_sftp/sftp/session.rb', line 8 def initialize(session, channel) @session, @channel = session, channel end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
6 7 8 |
# File 'lib/jsch_sftp/sftp/session.rb', line 6 def channel @channel end |
Class Method Details
.connect(jsch, user, host, options) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/jsch_sftp/sftp/session.rb', line 40 def self.connect(jsch, user, host, ) session = jsch.get_session(user, host) configure(session, ) session.connect channel = Channel.connect(session) self.new(session, channel) end |
Instance Method Details
#connected? ⇒ Boolean
12 13 14 |
# File 'lib/jsch_sftp/sftp/session.rb', line 12 def connected? session.is_connected end |
#disconnect ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/jsch_sftp/sftp/session.rb', line 32 def disconnect channel.disconnect unless channel.nil? if connected? session.disconnect rescue nil end end |
#download!(remote_filepath, local_filepath) ⇒ Object
16 17 18 |
# File 'lib/jsch_sftp/sftp/session.rb', line 16 def download!(remote_filepath, local_filepath) channel.download!(remote_filepath, local_filepath) end |
#entries(remote_path) ⇒ Object
20 21 22 |
# File 'lib/jsch_sftp/sftp/session.rb', line 20 def entries(remote_path) channel.entries(remote_path) end |
#mkdir(remote_path) ⇒ Object
28 29 30 |
# File 'lib/jsch_sftp/sftp/session.rb', line 28 def mkdir(remote_path) channel.mkdir(remote_path) end |
#upload!(local_filepath, remote_filepath) ⇒ Object
24 25 26 |
# File 'lib/jsch_sftp/sftp/session.rb', line 24 def upload!(local_filepath, remote_filepath) channel.upload!(local_filepath, remote_filepath) end |