Class: DRbQS::Server::TransferSetting
- Inherits:
-
Object
- Object
- DRbQS::Server::TransferSetting
- Defined in:
- lib/drbqs/server/transfer_setting.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#host ⇒ Object
Returns the value of attribute host.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #get_client(same_host) ⇒ Object
- #information ⇒ Object
-
#initialize(host, user, directory) ⇒ TransferSetting
constructor
A new instance of TransferSetting.
- #prepared_directory ⇒ Object
- #setup_server(directory, opts = {}) ⇒ Object
Constructor Details
#initialize(host, user, directory) ⇒ TransferSetting
Returns a new instance of TransferSetting.
8 9 10 11 12 13 |
# File 'lib/drbqs/server/transfer_setting.rb', line 8 def initialize(host, user, directory) @host = host @user = user @directory = directory @setup_server = false end |
Instance Attribute Details
#directory ⇒ Object
Returns the value of attribute directory.
6 7 8 |
# File 'lib/drbqs/server/transfer_setting.rb', line 6 def directory @directory end |
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/drbqs/server/transfer_setting.rb', line 6 def host @host end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/drbqs/server/transfer_setting.rb', line 6 def user @user end |
Instance Method Details
#get_client(same_host) ⇒ Object
37 38 39 |
# File 'lib/drbqs/server/transfer_setting.rb', line 37 def get_client(same_host) @setup_server ? DRbQS::Transfer::Client.new(@directory, same_host, @host, @user) : nil end |
#information ⇒ Object
19 20 21 22 23 |
# File 'lib/drbqs/server/transfer_setting.rb', line 19 def information info = "directory: #{@directory}" info << ", sftp: #{@user}@#{@host}" if @host && @user info end |
#prepared_directory ⇒ Object
15 16 17 |
# File 'lib/drbqs/server/transfer_setting.rb', line 15 def prepared_directory @setup_server && @directory end |
#setup_server(directory, opts = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/drbqs/server/transfer_setting.rb', line 25 def setup_server(directory, opts = {}) return nil if @setup_server @directory = directory || @directory return nil if !@directory @setup_server = true @directory = File.(@directory) FileUtils.mkdir_p(@directory) @host = opts[:host] || @host @user = opts[:user] || @user || ENV['USER'] true end |