Sha256: 2f7564e0bd2143fd59e238a69b170a8a7b18227cc744032186b37c6443b9e890
Contents?: true
Size: 944 Bytes
Versions: 2
Compression:
Stored size: 944 Bytes
Contents
require_relative "age/version" module Unicode module Age class UnknownAge < StandardError; end 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, 9.0, 10.0, 11.0, 12.0, 12.1, ].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) raise(UnknownAge, "The string contains unassigned codepoints, so the Unicode version required cannot be determined. This gem version supports Unicode upto version #{UNICODE_VERSION}.") 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unicode-age-2.2.0 | lib/unicode/age.rb |
unicode-age-2.1.0 | lib/unicode/age.rb |