class Origami::Name
Class representing a Name
Object
. Name
objects are strings which identify some PDF
file inner structures.
Public Class Methods
new(name = "")
click to toggle source
Creates a new Name
.
- name
-
A symbol representing the new
Name
value.
Calls superclass method
Origami::Object::new
# File lib/origami/name.rb, line 43 def initialize(name = "") unless name.is_a?(Symbol) or name.is_a?(::String) raise TypeError, "Expected type Symbol or String, received #{name.class}." end @value = name.to_s super() end
Public Instance Methods
<=>(name)
click to toggle source
# File lib/origami/name.rb, line 58 def <=>(name) return unless name.is_a?(Name) self.value <=> name.value end
to_obfuscated_str(prop = 2)
click to toggle source
Calls superclass method
Origami::Object#to_obfuscated_str
# 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
value()
click to toggle source
# File lib/origami/name.rb, line 53 def value @value.to_sym end
Also aliased as: to_sym