Module: Unicode::Age

Defined in:
lib/unicode/age.rb,
lib/unicode/age/version.rb

Constant Summary collapse

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,
].freeze
KNOWN_UNICODE_REGEXES =
KNOWN_UNICODE_VERSIONS.map{ |uv|
  begin
    /\A\p{age=#{"%.1f" % uv}}*\z/
  rescue RegexpError
  end
}.compact.freeze
VERSION =
"1.1.0".freeze
UNICODE_VERSION =
"9.0.0".freeze

Class Method Summary collapse

Class Method Details

.of(string) ⇒ Object



33
34
35
36
37
38
# File 'lib/unicode/age.rb', line 33

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