Method: Origami::Name#to_obfuscated_str

Defined in:
lib/origami/obfuscation.rb

#to_obfuscated_str(prop = 2) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/origami/obfuscation.rb', line 199

def to_obfuscated_str(prop = 2)
    name = @value.dup

    forbiddenchars = [ " ","#","\t","\r","\n","\0","[","]","<",">","(",")","%","/","\\" ]

    name.gsub!(/./) do |c|
        if rand(prop) == 0 or forbiddenchars.include?(c)
            hexchar = c.ord.to_s(16)
            hexchar = "0" + hexchar if hexchar.length < 2

            '#' + hexchar
        else
            c
        end
    end

    super(TOKENS.first + name)
end