class Trocla::Encryptions

Public Class Methods

[](enc) click to toggle source
# File lib/trocla/encryptions.rb, line 19
def [](enc)
  encryptions[enc.to_s.downcase]
end
all() click to toggle source
# File lib/trocla/encryptions.rb, line 23
def all
  Dir[ path '*' ].collect do |enc|
    File.basename(enc, '.rb').downcase
  end
end
available?(encryption) click to toggle source
# File lib/trocla/encryptions.rb, line 29
def available?(encryption)
  all.include?(encryption.to_s.downcase)
end

Private Class Methods

encryptions() click to toggle source
# File lib/trocla/encryptions.rb, line 34
def encryptions
  @@encryptions ||= Hash.new do |hash, encryption|
    encryption = encryption.to_s.downcase
    if File.exists?( path encryption )
      require "trocla/encryptions/#{encryption}"
      class_name = "Trocla::Encryptions::#{encryption.capitalize}"
      hash[encryption] = (eval class_name)
    else
      raise "Encryption #{encryption} is not supported!"
    end
  end
end
path(encryption) click to toggle source
# File lib/trocla/encryptions.rb, line 47
def path(encryption)
  File.expand_path(
    File.join(File.dirname(__FILE__), 'encryptions', "#{encryption}.rb")
  )
end