Class: P3libUtil
- Inherits:
-
Object
- Object
- P3libUtil
- Defined in:
- lib/refx/engine/p3lib/p3lib_util.rb
Overview
library for all helper classes
Class Method Summary collapse
-
.decode_args(args) ⇒ Object
base64 decode all strings in list.
-
.force_utf(args) ⇒ Object
force all strings to utf in list.
- .helper_newtempname(len) ⇒ Object
Class Method Details
.decode_args(args) ⇒ Object
base64 decode all strings in list
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/refx/engine/p3lib/p3lib_util.rb', line 14 def self.decode_args(args) decoded = [] args.each do | arg | if arg.is_a?(String) decoded << Base64.decode64(arg) else decoded << arg end end decoded end |
.force_utf(args) ⇒ Object
force all strings to utf in list
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/refx/engine/p3lib/p3lib_util.rb', line 28 def self.force_utf(args) forced = [] args.each do | arg | if arg.is_a?(String) arg.force_encoding('UTF-8') end forced << arg end forced end |
.helper_newtempname(len) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/refx/engine/p3lib/p3lib_util.rb', line 6 def self.helper_newtempname(len) chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a newpass = '' 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } return newpass end |