Class: RandomPassword::Base
- Inherits:
-
Object
- Object
- RandomPassword::Base
- Defined in:
- lib/random_password/base.rb
Constant Summary collapse
- LETTERS =
[*'a'..'z', *'A'..'Z'].freeze
- DIGITS =
[*'0'..'9'].freeze
- SYMBOLS =
%w(! " # $ % & ' ( ) * + , - . / \\ : ; ? @ [ ] ^ _ ` { | } ~).freeze
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(**options) ⇒ Base
constructor
A new instance of Base.
- #update(**options) ⇒ Object
Constructor Details
#initialize(**options) ⇒ Base
Returns a new instance of Base.
9 10 11 |
# File 'lib/random_password/base.rb', line 9 def initialize(**) update() end |
Instance Method Details
#generate ⇒ Object
13 14 15 |
# File 'lib/random_password/base.rb', line 13 def generate password_letters.shuffle(random: Random.new).join[0, @length] end |
#update(**options) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/random_password/base.rb', line 17 def update(**) @length = [:length].to_i @digits = [:digits].to_i @symbols = [:symbols].to_i self end |