Module: Kameleoon::Utils::Strval
- Defined in:
- lib/kameleoon/utils.rb
Class Method Summary collapse
Class Method Details
.obj_to_s(obj) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/kameleoon/utils.rb', line 53 def self.obj_to_s(obj) case obj when nil 'nil' when String "'#{obj}'" when Array "[#{obj.map { |v| obj_to_s(v) }.join(',')}]" when Hash sb = [] obj.each { |k, v| sb.push("#{obj_to_s(k)}:#{obj_to_s(v)}") } "{#{sb.join(',')}}" else obj.to_s end end |
.secret(secret) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/kameleoon/utils.rb', line 70 def self.secret(secret) hid_ch = '*' vis_count = 4 return 'nil' if secret.nil? length = secret.length return hid_ch * length if length <= vis_count hidden_length = [length - vis_count, vis_count].max secret[0, length - hidden_length] + hid_ch * hidden_length end |