# class Mail::Multibyte::Unicode::UnicodeDatabase

Holds static data from the Unicode database

### Constants

ATTRIBUTES

### Public Class Methods

dirname() click to toggle source

Returns the directory in which the data files are stored

    # File lib/mail/multibyte/unicode.rb, line 376
    def self.dirname
      File.dirname(__FILE__) + '/../values/'
    end

filename() click to toggle source

Returns the filename for the data file for this version

    # File lib/mail/multibyte/unicode.rb, line 381
    def self.filename
      File.expand_path File.join(dirname, "unicode_tables.dat")
    end

new() click to toggle source

    # File lib/mail/multibyte/unicode.rb, line 334
    def initialize
      @codepoints = Hash.new(Codepoint.new)
      @composition_exclusion = []
      @composition_map = {}
      @boundary = {}
      @cp1252 = {}
    end

### Public Instance Methods

===(other) click to toggle source

    # File lib/mail/multibyte/unicode.rb, line 363
    def ===(other)
      detect { |i| i === other } ? true : false
    end

load() click to toggle source

Loads the Unicode database and returns all the internal objects of UnicodeDatabase.

    # File lib/mail/multibyte/unicode.rb, line 353
    def load
      begin
        @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read }
      rescue => e
          raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), Mail::Multibyte is unusable")
      end

      # 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(*ATTRIBUTES)
      end
    end