Class: RsrGroup::User

Inherits:
Base
  • Object
show all
Defined in:
lib/rsr_group/user.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_CATALOG_FILENAME, Base::DEFAULT_DIR, Base::KEYDEALER_CATALOG_FILENAME, Base::KEYDEALER_DIR, Base::MAP_FILENAME, Base::QTY_FILENAME

Instance Method Summary collapse

Methods inherited from Base

connect

Constructor Details

#initialize(options = {}) ⇒ User

Returns a new instance of User.



4
5
6
7
# File 'lib/rsr_group/user.rb', line 4

def initialize(options = {})
  requires!(options, :username, :password)
  @options = options
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rsr_group/user.rb', line 9

def authenticated?
  connect(@options) do |ftp| 
    ftp.status
    ftp.close
  end
  return true
rescue RsrGroup::NotAuthenticated
  false
rescue Net::FTPPermError => e
  if e.message =~ /authentication failed/i
    return false
  else
    raise e
  end
end