lib/unicode/age.rb in unicode-age-1.1.0 vs lib/unicode/age.rb in unicode-age-2.0.0.pre
- old
+ new
@@ -1,9 +1,11 @@
require_relative "age/version"
module Unicode
module Age
+ class UnknownAge < StandardError; end
+
KNOWN_UNICODE_VERSIONS = [
1.1,
2.0,
2.1,
3.0,
@@ -29,10 +31,10 @@
rescue RegexpError
end
}.compact.freeze
def self.of(string)
- return nil if string =~ /\A\p{Unassigned}*\z/
+ raise(UnknownAge, "The string containts unassigned codepoints, so the Unicode version required cannot be determined. Your Ruby version supports Unicode #{UNICODE_VERSION}.") if string =~ /\A\p{Unassigned}*\z/
KNOWN_UNICODE_VERSIONS.find.with_index{ |uv, index|
string =~ KNOWN_UNICODE_REGEXES[index]
}
end
end