Loads the unicode database and returns all the internal objects of
UnicodeDatabase Once the values have been loaded, define attr_reader
methods for the instance variables.
# File activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb, line 39
def load
begin
@codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read }
rescue Exception => e
raise IOError.new("Couldn't load the unicode tables for UTF8Handler (#{e.message}), handler is unusable")
end
@codepoints ||= Hash.new(Codepoint.new)
@composition_exclusion ||= []
@composition_map ||= {}
@boundary ||= {}
@cp1252 ||= {}
# Redefine the === method so we can write shorter rules for grapheme cluster breaks
@boundary.each do |k,_|
@boundary[k].instance_eval do
def ===(other)
detect { |i| i === other } ? true : false
end
end if @boundary[k].kind_of?(Array)
end
# define attr_reader methods for the instance variables
class << self
attr_reader :codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252
end
end