Parent

Class Index [+]

Quicksearch

Test::Unit::Diff::UTF8Line

Constants

WIDE_CHARACTERS

from unicode.org/reports/tr11/

AMBIGUOUS

Public Class Methods

new(line) click to toggle source
     # File lib/test/unit/diff.rb, line 374
374:         def initialize(line)
375:           @line = line
376:           @characters = @line.unpack("U*")
377:         end
wide_character?(character) click to toggle source
     # File lib/test/unit/diff.rb, line 349
349:           def wide_character?(character)
350:             binary_search_ranges(character, WIDE_CHARACTERS) or
351:               binary_search_ranges(character, AMBIGUOUS)
352:           end

Private Class Methods

binary_search_ranges(character, ranges) click to toggle source
     # File lib/test/unit/diff.rb, line 355
355:           def binary_search_ranges(character, ranges)
356:             if ranges.size.zero?
357:               false
358:             elsif ranges.size == 1
359:               ranges[0].include?(character)
360:             else
361:               half = ranges.size / 2
362:               range = ranges[half]
363:               if range.include?(character)
364:                 true
365:               elsif character < range.begin
366:                 binary_search_ranges(character, ranges[0...half])
367:               else
368:                 binary_search_ranges(character, ranges[(half + 1)..1])
369:               end
370:             end
371:           end

Public Instance Methods

[](*args) click to toggle source
     # File lib/test/unit/diff.rb, line 379
379:         def [](*args)
380:           result = @characters[*args]
381:           if result.respond_to?(:pack)
382:             result.pack("U*")
383:           else
384:             result
385:           end
386:         end
compute_width(start, _end) click to toggle source
     # File lib/test/unit/diff.rb, line 400
400:         def compute_width(start, _end)
401:           width = 0
402:           start.upto(_end - 1) do |i|
403:             if self.class.wide_character?(@characters[i])
404:               width += 2
405:             else
406:               width += 1
407:             end
408:           end
409:           width
410:         end
each(&block) click to toggle source
     # File lib/test/unit/diff.rb, line 388
388:         def each(&block)
389:           @characters.each(&block)
390:         end
size() click to toggle source
     # File lib/test/unit/diff.rb, line 392
392:         def size
393:           @characters.size
394:         end
to_s() click to toggle source
     # File lib/test/unit/diff.rb, line 396
396:         def to_s
397:           @line
398:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.