Class: PasswordDialog
Constant Summary
collapse
- PROMPT =
'Enter password:'
- PRINTABLE_ASCII =
(32..126).to_a.pack 'C*'
Instance Attribute Summary
Attributes inherited from Message
#lines
Instance Method Summary
collapse
Methods included from Encryption
#decrypt, #encrypt, #key=, #make_cipher, #make_password_hash
Methods inherited from Message
#drawn?
Constructor Details
Returns a new instance of PasswordDialog.
11
12
13
14
15
|
# File 'lib/game_2d/password_dialog.rb', line 11
def initialize(window, font)
super(window, font, [PROMPT, '_'])
@text = @window.text_input = Gosu::TextInput.new
@draw_count = 0
end
|
Instance Method Details
#display_text ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/game_2d/password_dialog.rb', line 17
def display_text
size = password.size
return '_' if size.zero?
rand_char = PRINTABLE_ASCII[
(@draw_count / 10) * 53 % PRINTABLE_ASCII.size
]
rand_char * size
end
|
#draw ⇒ Object
26
27
28
29
30
|
# File 'lib/game_2d/password_dialog.rb', line 26
def draw
@draw_count += 1
self.lines = [PROMPT, display_text]
super
end
|
#enter ⇒ Object
32
33
34
|
# File 'lib/game_2d/password_dialog.rb', line 32
def enter
@window.text_input = nil
end
|
#password_hash ⇒ Object
41
42
43
|
# File 'lib/game_2d/password_dialog.rb', line 41
def password_hash
make_password_hash password
end
|