Class: Ghaki::Account::Base
- Inherits:
-
Object
- Object
- Ghaki::Account::Base
- Includes:
- EMailAddress, Hostname, Password, Username
- Defined in:
- lib/ghaki/account/base.rb
Constant Summary
Constants included from Password
Password::ASK_PASSWORD_RETRY_MAX
Constants included from Username
Constants included from Hostname
Instance Attribute Summary
Attributes included from EMailAddress
Attributes included from Username
Attributes included from Hostname
Class Method Summary collapse
-
.from_opts(opts) ⇒ Object
CLASS METHODS.
- .purge_opts(opts) ⇒ Object
Instance Method Summary collapse
- #ask_all(opts = {}) ⇒ Object
- #collapse_opts(opts = {}) ⇒ Object
- #expand_opts(opts = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ Base
constructor
OBJECT METHODS.
- #to_s ⇒ Object
Methods included from SynOpts
Methods included from Password
#ask_password, #fail_password, #failed_passwords?, #opt_password, #password, #passwords, #passwords=, #reset_passwords, #retry_password?, #valid_password?
Methods included from Username
#ask_username, get_env, #valid_username?
Methods included from Hostname
#ask_hostname, get_env, #valid_hostname?
Constructor Details
#initialize(opts = {}) ⇒ Base
OBJECT METHODS
37 38 39 |
# File 'lib/ghaki/account/base.rb', line 37 def initialize opts={} _from_opts opts end |
Class Method Details
.from_opts(opts) ⇒ Object
CLASS METHODS
20 21 22 |
# File 'lib/ghaki/account/base.rb', line 20 def self.from_opts opts opts[:account] || Base.new(opts) end |
.purge_opts(opts) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/ghaki/account/base.rb', line 24 def self.purge_opts opts Hostname.purge_opts opts Username.purge_opts opts Password.purge_opts opts EMailAddress.purge_opts opts opts.delete(:account) opts end |
Instance Method Details
#ask_all(opts = {}) ⇒ Object
60 61 62 63 64 |
# File 'lib/ghaki/account/base.rb', line 60 def ask_all opts={} ask_hostname opts[:hostname_opts] || {} ask_username opts[:username_opts] || {} ask_password opts[:password_opts] || {} end |
#collapse_opts(opts = {}) ⇒ Object
50 51 52 53 54 |
# File 'lib/ghaki/account/base.rb', line 50 def collapse_opts opts={} self.class.purge_opts opts opts[:account] = self opts end |
#expand_opts(opts = {}) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/ghaki/account/base.rb', line 41 def opts={} opts.delete(:account) opts[:hostname] = @hostname unless @hostname.nil? opts[:username] = @username unless @username.nil? opts[:password] = self.passwords unless passwords.empty? opts[:email_address] = @email_address unless @email_address.nil? opts end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/ghaki/account/base.rb', line 56 def to_s (@username || '*') + '@' + (@hostname || '*') end |