Sha256: 06b49c90a59f51814952eeb0a1614ef1161c77af7c26234a856be43f699f85bb

Contents?: true

Size: 668 Bytes

Versions: 1

Compression:

Stored size: 668 Bytes

Contents

require_relative "age/version"

module Unicode
  module Age
    KNOWN_UNICODE_VERSIONS = [
      1.1,
      2.0,
      2.1,
      3.0,
      3.1,
      3.2,
      4.0,
      4.1,
      5.0,
      5.1,
      5.2,
      6.0,
      6.1,
      6.2,
      6.3,
      7.0,
      8.0,
    ].freeze

    KNOWN_UNICODE_REGEXES = KNOWN_UNICODE_VERSIONS.map{ |uv|
      begin
        /\A\p{age=#{"%.1f" % uv}}*\z/
      rescue RegexpError
      end
    }.compact.freeze

    def self.of(string)
      return nil if string =~ /\A\p{Unassigned}*\z/
      KNOWN_UNICODE_VERSIONS.find.with_index{ |uv, index|
        string =~ KNOWN_UNICODE_REGEXES[index]
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unicode-age-1.0.1 lib/unicode/age.rb