Module: Ghaki::Account::UserDomain

Extended by:
SynOpts
Included in:
WinDos
Defined in:
lib/ghaki/account/userdomain.rb

Constant Summary collapse

USERDOMAIN_RETRY_MAX =

CONSTANTS

3

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SynOpts

attr_syn_opts

Instance Attribute Details

#userdomainObject

OBJECT METHODS



32
33
34
# File 'lib/ghaki/account/userdomain.rb', line 32

def userdomain
  @userdomain
end

Class Method Details

.get_envObject




25
26
27
# File 'lib/ghaki/account/userdomain.rb', line 25

def UserDomain.get_env
  ENV['USERDOMAIN']
end

Instance Method Details

#ask_userdomain(opts = {}) ⇒ Object




55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ghaki/account/userdomain.rb', line 55

def ask_userdomain opts={}
  o_prompt,r_prompt = _userdomain_prompt(opts), nil
  defval = opts[:default] || @userdomain
  defval = UserDomain.get_env if defval == :env
  (1 .. (opts[:retry_max] || USERDOMAIN_RETRY_MAX) ).each do
    self.userdomain = HighLine.new.ask( r_prompt||o_prompt ) do |q|
      q.echo = true
      q.default = defval unless defval.nil?
    end
    return @userdomain if valid_userdomain?
    r_prompt ||= '* TRY AGAIN * ' + o_prompt
  end
  raise InvalidUserDomainError, "Invalid User Domain: #{@userdomain}"
end

#valid_userdomain?Boolean


Returns:

  • (Boolean)


47
48
49
50
51
52
# File 'lib/ghaki/account/userdomain.rb', line 47

def valid_userdomain?
  return false if @userdomain.nil?
  return false if @userdomain.empty?
  return false unless @userdomain =~ %r{\A\w+\z}o
  return true
end