Class: FtpBrowserApi
- Inherits:
-
Object
- Object
- FtpBrowserApi
- Defined in:
- lib/graphiclious/ftp_browser.rb
Instance Method Summary collapse
-
#initialize(options_file, subdir) ⇒ FtpBrowserApi
constructor
A new instance of FtpBrowserApi.
- #load_options ⇒ Object
- #run(main_win) ⇒ Object
- #save_options ⇒ Object
Constructor Details
#initialize(options_file, subdir) ⇒ FtpBrowserApi
Returns a new instance of FtpBrowserApi.
8 9 10 11 12 13 14 |
# File 'lib/graphiclious/ftp_browser.rb', line 8 def initialize(, subdir) @options_file = @options = @options.localDestinationPath = File.join(File.dirname(@options_file), subdir) @options.ftpConnectionTimeout = 600 unless @options.ftpConnectionTimeout > 600 @options.ftpTransferTimeout = 2000 unless @options.ftpTransferTimeout > 2000 end |
Instance Method Details
#load_options ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/graphiclious/ftp_browser.rb', line 22 def return PiggyOptions.new unless File.exists?(@options_file) begin config = File.open(@options_file) { |io| YAML.load(io) } if config.class == Array = config.detect{ |entry| entry.class == PiggyOptions } else = config end .initializeNilsWithDefault rescue StandardError => ex puts('Configuration error, options.yaml ignored: ' + ex.) = PiggyOptions.new end return end |
#run(main_win) ⇒ Object
16 17 18 19 20 |
# File 'lib/graphiclious/ftp_browser.rb', line 16 def run main_win uploadDialog = FtpBrowserDialog.new(main_win, @options) uploadDialog.execute end |
#save_options ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/graphiclious/ftp_browser.rb', line 39 def begin if File.exists?(@options_file) File.rename(@options_file, "#{@options_file}.bak") end File.open(@options_file, 'w') { |out| YAML.dump(@options, out) } puts "Options saved to #{@options_file}" rescue StandardError => ex puts "Options could not be saved to #{@options_file}: " + ex. end end |