Holds static data from the Unicode database
Methods
Constants
ATTRIBUTES | = | :codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252 |
Public Class methods
Returns the directory in which the data files are stored
[ show source ]
# File activesupport/lib/active_support/multibyte/unicode_database.rb, line 59 59: def self.dirname 60: File.dirname(__FILE__) + '/../values/' 61: end
Returns the filename for the data file for this version
[ show source ]
# File activesupport/lib/active_support/multibyte/unicode_database.rb, line 64 64: def self.filename 65: File.expand_path File.join(dirname, "unicode_tables.dat") 66: end
[ show source ]
# File activesupport/lib/active_support/multibyte/unicode_database.rb, line 16 16: def initialize 17: @codepoints = Hash.new(Codepoint.new) 18: @composition_exclusion = [] 19: @composition_map = {} 20: @boundary = {} 21: @cp1252 = {} 22: end
Public Instance methods
[ show source ]
# File activesupport/lib/active_support/multibyte/unicode_database.rb, line 46 46: def ===(other) 47: detect { |i| i === other } ? true : false 48: end
Loads the Unicode database and returns all the internal objects of UnicodeDatabase.
[ show source ]
# File activesupport/lib/active_support/multibyte/unicode_database.rb, line 36 36: def load 37: begin 38: @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read } 39: rescue Exception => e 40: raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable") 41: end 42: 43: # Redefine the === method so we can write shorter rules for grapheme cluster breaks 44: @boundary.each do |k,_| 45: @boundary[k].instance_eval do 46: def ===(other) 47: detect { |i| i === other } ? true : false 48: end 49: end if @boundary[k].kind_of?(Array) 50: end 51: 52: # define attr_reader methods for the instance variables 53: class << self 54: attr_reader(*ATTRIBUTES) 55: end 56: end