Class: Imap::Backup::Setup::Asker
- Inherits:
-
Object
- Object
- Imap::Backup::Setup::Asker
- Defined in:
- lib/imap/backup/setup/asker.rb
Constant Summary collapse
- EMAIL_MATCHER =
/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+$/i.freeze
Instance Attribute Summary collapse
-
#highline ⇒ Object
readonly
Returns the value of attribute highline.
Class Method Summary collapse
Instance Method Summary collapse
- #email(default = "") ⇒ Object
-
#initialize(highline) ⇒ Asker
constructor
A new instance of Asker.
- #password ⇒ Object
Constructor Details
#initialize(highline) ⇒ Asker
Returns a new instance of Asker.
9 10 11 |
# File 'lib/imap/backup/setup/asker.rb', line 9 def initialize(highline) @highline = highline end |
Instance Attribute Details
#highline ⇒ Object (readonly)
Returns the value of attribute highline.
7 8 9 |
# File 'lib/imap/backup/setup/asker.rb', line 7 def highline @highline end |
Class Method Details
Instance Method Details
#email(default = "") ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/imap/backup/setup/asker.rb', line 13 def email(default = "") highline.ask("email address: ") do |q| q.default = default q.readline = true q.validate = EMAIL_MATCHER q.responses[:not_valid] = "Enter a valid email address " end end |
#password ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/imap/backup/setup/asker.rb', line 22 def password password = highline.ask("password: ") { |q| q.echo = false } confirmation = highline.ask("repeat password: ") { |q| q.echo = false } if password != confirmation return nil if !highline.agree( "the password and confirmation did not match.\nContinue? (y/n) " ) return self.password end password end |