Class: ToPass::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/to_pass/base.rb

Overview

ToPass::Base is mostly a facade for the library.

Given a string and a algorithm identifier, the right rules are loaded and applied to the string. With a simple “to_s”, you can get the final password. The password is also readable directly through ToPass::Base#password.

see ToPass::AlgorithmReader and ToPass::Converter for details

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, algorithm, options = {}) ⇒ Base

transform a string according to a certain algorithm



16
17
18
19
20
21
# File 'lib/to_pass/base.rb', line 16

def initialize(string, algorithm, options = {})
  Directories[:custom] = options[:path] if options[:path]
  rules = AlgorithmReader.load(algorithm)
  converter = Converter.new(rules)
  @password = converter.convert(string)
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



13
14
15
# File 'lib/to_pass/base.rb', line 13

def password
  @password
end

Instance Method Details

#to_sObject

return the generated password



24
25
26
# File 'lib/to_pass/base.rb', line 24

def to_s
  password
end