mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 21:10:54 +00:00
22 lines
No EOL
489 B
Ruby
22 lines
No EOL
489 B
Ruby
module Verification
|
|
def Verification.uncrap str
|
|
str.to_s.gsub(/[^A-Za-z0-9_\-]/, "")
|
|
end
|
|
|
|
def Verification.random_string len
|
|
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
|
str = ""
|
|
1.upto(len) do |i|
|
|
str << chars[rand(chars.size-1)]
|
|
end
|
|
return str
|
|
end
|
|
|
|
# TODO: rikki?
|
|
def Verification.contain params, filter
|
|
(params.instance_of?(Array) ? params : params.keys).each do |key|
|
|
return false unless filter.include? key.to_sym
|
|
end
|
|
return true
|
|
end
|
|
end |