Sha256: 2efc22424e19bdbeacda702386aa0b34a813725bd0339f3b18aed6b2a0203cd9

Contents?: true

Size: 878 Bytes

Versions: 4

Compression:

Stored size: 878 Bytes

Contents

module Unicoder
  module Builder
    class NumericValue
      include Builder

      def initialize_index
        @index = {
          NUMBERS: {},
        }
      end

      def parse!
        parse_file :unicode_data, :line, regex: /^(?<codepoint>.+?);(.*?;){7}(?<value>.*?);.*$/ do |line|
          unless line["value"].empty?
            if line["value"] =~ %r</>
              
              assign :NUMBERS, line["codepoint"].to_i(16), option =~ /stringfractions/ ? "#{line["value"]}" : line["value"].to_r
            else
              assign :NUMBERS, line["codepoint"].to_i(16), line["value"].to_i
            end
          end
        end

        parse_file :unihan_numeric_values, :line, regex: /^U\+(?<codepoint>\S+)\s+\S+\s+(?<value>\S+)$/ do |line|
          assign :NUMBERS, line["codepoint"].to_i(16), line["value"].to_i
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unicoder-1.3.0 lib/unicoder/builders/numeric_value.rb
unicoder-1.1.1 lib/unicoder/builders/numeric_value.rb
unicoder-1.1.0 lib/unicoder/builders/numeric_value.rb
unicoder-1.0.0 lib/unicoder/builders/numeric_value.rb