Sha256: 5cadf0b2d1bab425b504ef8556385d06e0084f29e22caa18b2a928806b1ed437

Contents?: true

Size: 807 Bytes

Versions: 118

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

require "zlib"
require_relative "constants"

module Unicode
  class DisplayWidth
    File.open(INDEX_FILENAME, "rb") do |file|
      serialized_data = Zlib::GzipReader.new(file).read
      serialized_data.force_encoding Encoding::BINARY
      INDEX = Marshal.load(serialized_data)
    end

    def self.decompress_index(index, level)
      index.flat_map{ |value|
        if level > 0
          if value.instance_of?(Array)
            value[15] ||= nil
            decompress_index(value, level - 1)
          else
            decompress_index([value] * 16, level - 1)
          end
        else
          if value.instance_of?(Array)
            value[15] ||= nil
            value
          else
            [value] * 16
          end
        end
      }
    end
  end
end

Version data entries

118 entries across 118 versions & 18 rubygems

Version Path
harbr-0.1.53 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.52 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.50 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.49 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.48 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.47 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.39 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.38 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
harbr-0.1.37 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
study_line-0.1.6 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
study_line-0.1.5 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
study_line-0.1.4 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb
study_line-0.1.3 vendor/bundle/ruby/3.2.0/gems/unicode-display_width-2.5.0/lib/unicode/display_width/index.rb