Class: Password

Inherits:
Object
  • Object
show all
Defined in:
lib/ppg/password.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(password_length, password_pattern = nil) ⇒ Password

Returns a new instance of Password.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/ppg/password.rb', line 5

def initialize (password_length, password_pattern = nil)
  raise ArgumentError, "length must be > 0" if password_length <= 0
  @PASSWORD_LENGTH = password_length.freeze
  @password = String.new
  #TODO: make password_pattern validation check method
  @password_pattern ||= []
end

Instance Attribute Details

#passwordObject Also known as: to_s

Returns the value of attribute password.



2
3
4
# File 'lib/ppg/password.rb', line 2

def password
  @password
end

#PASSWORD_LENGTHObject (readonly)

Returns the value of attribute PASSWORD_LENGTH.



3
4
5
# File 'lib/ppg/password.rb', line 3

def PASSWORD_LENGTH
  @PASSWORD_LENGTH
end

#password_patternObject

Returns the value of attribute password_pattern.



2
3
4
# File 'lib/ppg/password.rb', line 2

def password_pattern
  @password_pattern
end

Instance Method Details

#length=(password_length) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
# File 'lib/ppg/password.rb', line 13

def length= (password_length)
  raise ArgumentError, "length must be > 0" if password_length <= 0
  @PASSWORD_LENGTH = password_length.freeze
end