Sha256: 8a07981154e0972a12aa7b2a83661ad2636f034ea3a3b44c783069cbc880c429

Contents?: true

Size: 854 Bytes

Versions: 3

Compression:

Stored size: 854 Bytes

Contents

require "unicode/eaw/version"
require "unicode/eaw/data"

module Unicode
  module Eaw
    class Error < StandardError; end

    def property(ch)
      cp = ch[0].ord
      left = 0
      right = DATA.length - 1
      while left <= right
        middle = Integer(left + (right - left) / 2);
        range = DATA[middle]
        if cp < range[1]
          right = middle - 1
          next
        else
          end_n = range[1]
          if range.length == 3
            end_n = range[1] + range[2]
          end
          if cp > end_n
            left = middle + 1
            next
          else
            type = TYPES[range[0]]
            if !type
              raise Error, "Unexpected type: #{range[0]}"
            end
            return type
          end
        end
      end
      return :N
    end

    module_function :property
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
unicode-eaw-2.2.0 lib/unicode/eaw.rb
unicode-eaw-2.1.0 lib/unicode/eaw.rb
unicode-eaw-2.0.0 lib/unicode/eaw.rb