Method: Origami::Name.contract
- Defined in:
- lib/origami/name.rb
.contract(name) ⇒ Object
:nodoc:
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/origami/name.rb', line 96 def self.contract(name) #:nodoc: i = 0 name = name.dup while i < name.length if name[i] == "#" digits = name[i+1, 2] unless /^[A-Za-z0-9]{2}$/ === digits raise InvalidNameObjectError, "Irregular use of # token" end char = digits.hex.chr if char == "\0" raise InvalidNameObjectError, "Null byte forbidden inside name definition" end name[i, 3] = char end i = i + 1 end name end |