Class: ADAM6050::Password
- Inherits:
-
Object
- Object
- ADAM6050::Password
- Defined in:
- lib/adam6050/password.rb
Overview
Usage
The following example creates a password and uses it to validate an encoded string.
password = Password.new 'b6TSkfr6'
password == 'b6TSkfr6' # => false
password == "]\tklTYM\t" # => true
The next example creates a password that will match any string.
password = Password.new
password == 'anything' # => true
Defined Under Namespace
Classes: FormatError
Instance Method Summary collapse
-
#initialize(plain = nil) ⇒ Password
constructor
A new instance of Password.
Constructor Details
#initialize(plain = nil) ⇒ Password
Returns a new instance of Password.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/adam6050/password.rb', line 32 def initialize(plain = nil) if plain password = obfuscate plain define_singleton_method(:==) { |text| password == text } else define_singleton_method(:==) { |_| true } end freeze end |