Sha256: 869205917a8c0b8f4bed9536a0d83db199d2e8d7d9a3272d5901898198457027

Contents?: true

Size: 1.03 KB

Versions: 41

Compression:

Stored size: 1.03 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Resources
    module Properties

      class BidiBracketsPropertyImporter < PropertyImporter
        DATA_FILE = 'ucd/BidiBrackets.txt'
        PROPERTY_NAME = 'Bidi_Paired_Bracket_Type'

        requirement :unicode, Versions.unicode_version, [DATA_FILE]
        output_path 'unicode_data/properties'
        ruby_engine :mri

        def property_name
          PROPERTY_NAME
        end

        private

        def source_path
          requirements[:unicode].source_path_for(DATA_FILE)
        end

        def load
          super do |data, ret|
            code_points = expand_range(data[0])
            paired_bracket_type = infer_paired_bracket_type(data[2])
            ret[PROPERTY_NAME][paired_bracket_type] += code_points
          end
        end

        def infer_paired_bracket_type(str)
          TwitterCldr::Shared::Properties::BidiBrackets.bracket_types[str.upcase]
        end
      end

    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
twitter_cldr-4.1.0 lib/twitter_cldr/resources/properties/bidi_brackets_property_importer.rb