Class: ActiveSupport::Multibyte::Handlers::UnicodeDatabase
- Defined in:
- lib/active_support/multibyte/handlers/utf8_handler.rb,
lib/active_support/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
10 11 12 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 10 def boundary=(value) @boundary = value end |
#codepoints=(value) ⇒ Object (writeonly)
Sets the attribute codepoints
10 11 12 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 10 def codepoints=(value) @codepoints = value end |
#composition_exclusion=(value) ⇒ Object (writeonly)
Sets the attribute composition_exclusion
10 11 12 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 10 def composition_exclusion=(value) @composition_exclusion = value end |
#composition_map=(value) ⇒ Object (writeonly)
Sets the attribute composition_map
10 11 12 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 10 def composition_map=(value) @composition_map = value end |
#cp1252=(value) ⇒ Object (writeonly)
Sets the attribute cp1252
10 11 12 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 10 def cp1252=(value) @cp1252 = value end |
Class Method Details
.dirname ⇒ Object
Returns the directory in which the data files are stored
26 27 28 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 26 def self.dirname File.dirname(__FILE__) + '/../../values/' end |
.filename ⇒ Object
Returns the filename for the data file for this version
31 32 33 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 31 def self.filename File. File.join(dirname, "unicode_tables.dat") end |
Instance Method Details
#[](index) ⇒ Object
Shortcut to ucd.codepoints[]
23 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 23 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.
37 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 |
# File 'lib/active_support/multibyte/handlers/utf8_handler.rb', line 37 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 |