Class Origami::Name
In: sources/parser/obfuscation.rb
sources/parser/name.rb
Parent: Object

Class representing a Name Object. Name objects are strings which identify some PDF file inner structures.

Methods

new   real_type   set   to_obfuscated_str   value  

Included Modules

Origami::Object

Public Class methods

Creates a new Name.

name:A symbol representing the new Name value.

[Source]

    # File sources/parser/name.rb, line 51
51:     def initialize(name = "", indirect = false)
52:       
53:       unless name.is_a?(Symbol) or name.is_a?(::String)
54:         raise TypeError, "Expected type Symbol or String, received #{name.class}."
55:       end
56:       
57:       value = (name.to_s.empty?) ? " "" " : name.to_sym
58:       
59:       super(indirect, value)
60:       
61:     end

Public Instance methods

[Source]

     # File sources/parser/name.rb, line 145
145:     def real_type ; Name end

[Source]

    # File sources/parser/name.rb, line 63
63:     def set(value)
64:       initialize(value, @indirect)
65:     end

[Source]

     # File sources/parser/obfuscation.rb, line 181
181:     def to_obfuscated_str(prop = 2)
182:       name = (self.value == " "" ") ? "" : self.id2name
183:       
184:       forbiddenchars = [ " ","#","\t","\r","\n","\0","[","]","<",">","(",")","%","/","\\" ]
185: 
186:       name.gsub!(/./) do |c|
187:         if rand(prop) == 0 or forbiddenchars.include?(c)
188:           hexchar = c[0].to_s(base=16)
189:           hexchar = "0" + hexchar if hexchar.length < 2
190:           
191:           '#' + hexchar
192:         else
193:           c
194:         end
195:       end
196: 
197:       print(TOKENS.first + name)
198:     end

[Source]

    # File sources/parser/name.rb, line 67
67:     def value
68:       self.to_sym
69:     end

[Validate]