Class: SpecialCasing
- Inherits:
-
Object
- Object
- SpecialCasing
- Defined in:
- ext/encoding/character/utf-8/data/generate-unicode-data.rb
Instance Method Summary collapse
-
#initialize ⇒ SpecialCasing
constructor
A new instance of SpecialCasing.
- #process(data) ⇒ Object
Constructor Details
#initialize ⇒ SpecialCasing
Returns a new instance of SpecialCasing.
286 287 288 |
# File 'ext/encoding/character/utf-8/data/generate-unicode-data.rb', line 286 def initialize @offset = 0 end |
Instance Method Details
#process(data) ⇒ Object
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'ext/encoding/character/utf-8/data/generate-unicode-data.rb', line 290 def process(data) path = File.join(data.dir, 'SpecialCasing.txt') File.process(path) do |line| fields = line.chomp.sub(/\s*#.*/, '').split(/\s*;\s*/, -1) fields.verify_size((5..6), path, CASE_CODE) raw_code, code = fields[CASE_CODE], fields[CASE_CODE].to_i(16) unless data.type[code].nil? # We ignore conditional special cases next if fields.size == 6 case data.type[code] when 'Lu' fields.verify_field(CASE_UPPER, code, path, raw_code, 'Lu', 'Upper') add_special_case(data, code, data.value[code], fields[CASE_LOWER], fields[CASE_TITLE]) when 'Lt' fields.verify_field(CASE_TITLE, code, path, raw_code, 'Lt', 'Title') add_special_case(data, code, nil, fields[CASE_LOWER], fields[CASE_UPPER]) when 'Ll' fields.verify_field(CASE_LOWER, code, path, raw_code, 'Ll', 'Lower') add_special_case(data, code, data.value[code], fields[CASE_UPPER], fields[CASE_TITLE]) else error("special case for non-alphabetic code point:\n" + " file: %s\n" + " type: %s\n" + " code point/entry: %s\n", path, data.type[code], raw_code) end else error("special case for code point which doesn't have a type:\n" + " file: %s\n" + " code point/entry: %d\n", path, code) end end end |