Class: FunWith::Passwords::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/fun_with/passwords/console.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConsole

Returns a new instance of Console.



6
7
8
# File 'lib/fun_with/passwords/console.rb', line 6

def initialize
  @pre_inputs = []
end

Instance Attribute Details

#pre_inputsObject

Returns the value of attribute pre_inputs.



4
5
6
# File 'lib/fun_with/passwords/console.rb', line 4

def pre_inputs
  @pre_inputs
end

Instance Method Details

#ask_for_asterisks(msg) ⇒ Object



28
29
30
# File 'lib/fun_with/passwords/console.rb', line 28

def ask_for_asterisks( msg )
  ask( msg ){ |q| q.echo = "*" }
end

#ask_for_master_key(file) ⇒ Object



16
17
18
# File 'lib/fun_with/passwords/console.rb', line 16

def ask_for_master_key( file )
  ask_for_asterisks( "Enter the master key to unlock #{file}: " )
end

#ask_for_new_master_key(file) ⇒ Object



20
21
22
# File 'lib/fun_with/passwords/console.rb', line 20

def ask_for_new_master_key( file )
  ask_for_asterisks( "Enter the NEW master key for #{file}: " )
end

#ask_for_password(key = nil) ⇒ Object



10
11
12
13
14
# File 'lib/fun_with/passwords/console.rb', line 10

def ask_for_password( key = nil )
  key ||= ask( "Enter the key associated with the password: ")
  pass = ask_for_asterisks( "Enter the password for key #{key}: " )
  [key, pass]
end

#confirm(q) ⇒ Object



24
25
26
# File 'lib/fun_with/passwords/console.rb', line 24

def confirm( q )
  ask( "#{q} (Y/N)").upcase == "Y"
end