Class: Multibyte::Handlers::UnicodeDatabase
- Inherits:
-
Object
- Object
- Multibyte::Handlers::UnicodeDatabase
- Defined in:
- lib/multibyte/handlers/utf8_handler.rb,
lib/multibyte/generators/generate_tables.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#boundary ⇒ Object
writeonly
Sets the attribute boundary.
-
#codepoints ⇒ Object
writeonly
Sets the attribute codepoints.
-
#composition_exclusion ⇒ Object
writeonly
Sets the attribute composition_exclusion.
-
#composition_map ⇒ Object
writeonly
Sets the attribute composition_map.
-
#cp1252 ⇒ Object
writeonly
Sets the attribute cp1252.
Class Method Summary collapse
-
.dirname ⇒ Object
Returns the directory in which the data files are stored.
-
.filename ⇒ Object
Returns the filename for the data file for this version.
- .load ⇒ Object
Instance Method Summary collapse
-
#[](index) ⇒ Object
Shortcut to ucd.codepoints[].
-
#load ⇒ Object
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.
Instance Attribute Details
#boundary=(value) ⇒ Object (writeonly)
Sets the attribute boundary
11 12 13 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 11 def boundary=(value) @boundary = value end |
#codepoints=(value) ⇒ Object (writeonly)
Sets the attribute codepoints
11 12 13 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 11 def codepoints=(value) @codepoints = value end |
#composition_exclusion=(value) ⇒ Object (writeonly)
Sets the attribute composition_exclusion
11 12 13 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 11 def composition_exclusion=(value) @composition_exclusion = value end |
#composition_map=(value) ⇒ Object (writeonly)
Sets the attribute composition_map
11 12 13 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 11 def composition_map=(value) @composition_map = value end |
#cp1252=(value) ⇒ Object (writeonly)
Sets the attribute cp1252
11 12 13 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 11 def cp1252=(value) @cp1252 = value end |
Class Method Details
.dirname ⇒ Object
Returns the directory in which the data files are stored
27 28 29 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 27 def self.dirname File.dirname(__FILE__) + '/' end |
.filename ⇒ Object
Returns the filename for the data file for this version
32 33 34 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 32 def self.filename File. File.join(dirname, "unicode_tables.dat") end |
.load ⇒ Object
10 11 12 |
# File 'lib/multibyte/generators/generate_tables.rb', line 10 def self.load [Hash.new(Codepoint.new),[],{},{}] end |
Instance Method Details
#[](index) ⇒ Object
Shortcut to ucd.codepoints[]
24 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 24 def [](index); codepoints[index]; end |
#load ⇒ Object
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.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/multibyte/handlers/utf8_handler.rb', line 38 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.}), 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 |