Method: Unicode.const_missing
- Defined in:
- lib/rex/text/unicode.rb
.const_missing(name) ⇒ Object
289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/rex/text/unicode.rb', line 289 def self.const_missing(name) # Check that the constant name is of the right form: U0000 to U10FFFF if name.to_s =~ /^U([0-9a-fA-F]{4,5}|10[0-9a-fA-F]{4})$/ # Convert the codepoint to an immutable UTF-8 string, # define a real constant for that value and return the value #p name, name.class const_set(name, [$1.to_i(16)].pack("U").freeze) else # Raise an error for constants that are not Unicode. raise NameError, "Uninitialized constant: Unicode::#{name}" end end |