Sha256: b99782ca41f88ebcad430a94e37c5f1151f82e2a2ff2f64c6267b6048cf0a34f

Contents?: true

Size: 844 Bytes

Versions: 2

Compression:

Stored size: 844 Bytes

Contents

# vim:ft=ruby:fileencoding=utf-8

module ToPass
  # 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
  class Base
    attr_reader :password

    # transform a string according to a certain algorithm
    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

    # return the generated password
    def to_s
      password
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
to_pass-1.0.1 lib/to_pass/base.rb
to_pass-1.0.0 lib/to_pass/base.rb