Class: Rtprov::Sftp
- Inherits:
-
Object
- Object
- Rtprov::Sftp
- Defined in:
- lib/rtprov/sftp.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #get(src) ⇒ Object
-
#initialize(host, user, password) ⇒ Sftp
constructor
A new instance of Sftp.
- #put(src, dest) ⇒ Object
Constructor Details
#initialize(host, user, password) ⇒ Sftp
Returns a new instance of Sftp.
8 9 10 11 12 |
# File 'lib/rtprov/sftp.rb', line 8 def initialize(host, user, password) @host = host.dup.freeze @user = user.dup.freeze @password = password.dup.freeze end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/rtprov/sftp.rb', line 6 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
6 7 8 |
# File 'lib/rtprov/sftp.rb', line 6 def password @password end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/rtprov/sftp.rb', line 6 def user @user end |
Instance Method Details
#get(src) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/rtprov/sftp.rb', line 14 def get(src) Dir.mktmpdir do |dir| dest = File.join(dir, File.basename(src)) run "get #{src} -o #{dest}" File.read(dest) end end |
#put(src, dest) ⇒ Object
22 23 24 |
# File 'lib/rtprov/sftp.rb', line 22 def put(src, dest) run "put #{src} -o #{dest}" end |