Class: ActiveSupport::Multibyte::Unicode::UnicodeDatabase
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activesupport/lib/active_support/multibyte/unicode.rb |
Overview
Holds static data from the ::ActiveSupport::Multibyte::Unicode
database.
Constant Summary
-
ATTRIBUTES =
# File 'activesupport/lib/active_support/multibyte/unicode.rb', line 314:codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252
Class Method Summary
-
.dirname
Returns the directory in which the data files are stored.
-
.filename
Returns the filename for the data file for this version.
- .new ⇒ UnicodeDatabase constructor
Instance Method Summary
-
#load
Loads the
::ActiveSupport::Multibyte::Unicode
database and returns all the internal objects ofUnicodeDatabase
.
Constructor Details
.new ⇒ UnicodeDatabase
Class Method Details
.dirname
Returns the directory in which the data files are stored.
# File 'activesupport/lib/active_support/multibyte/unicode.rb', line 361
def self.dirname File. ("../values", __dir__) end
.filename
Returns the filename for the data file for this version.
Instance Method Details
#load
Loads the ::ActiveSupport::Multibyte::Unicode
database and returns all the internal objects of UnicodeDatabase
.
# File 'activesupport/lib/active_support/multibyte/unicode.rb', line 338
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.}), ActiveSupport::Multibyte is unusable") end # Redefine the === method so we can write shorter rules for grapheme cluster breaks @boundary.each_key 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