Module: Unicode::SequenceName

Defined in:
lib/unicode/sequence_name.rb,
lib/unicode/sequence_name/index.rb,
lib/unicode/sequence_name/constants.rb

Constant Summary collapse

VERSION =
"1.9.0"
UNICODE_VERSION =
"13.0.0"
EMOJI_VERSION =
"13.1"
IVD_VERSION =
"2020-11-06"
DATA_DIRECTORY =
File.expand_path(File.dirname(__FILE__) + "/../../../data/").freeze
INDEX_FILENAME =
(DATA_DIRECTORY + "/sequence_name.marshal.gz").freeze

Class Method Summary collapse

Class Method Details

.get_codepoint_values(string) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/unicode/sequence_name.rb', line 16

def self.get_codepoint_values(string)
  if string.valid_encoding?
    return string.codepoints
  elsif string.encoding.name == "UTF-8"
    begin
      return string.unpack("U*")
    rescue ArgumentError
    end
  end

  raise(ArgumentError, "Unicode::SequenceName.of must be given a valid string")
end

.sequence_name(string) ⇒ Object Also known as: of



5
6
7
8
9
10
11
12
13
# File 'lib/unicode/sequence_name.rb', line 5

def self.sequence_name(string)
  codepoints = get_codepoint_values(string)
  require_relative "sequence_name/index" unless defined? ::Unicode::SequenceName::INDEX
  if res = INDEX[codepoints]
    res
  else
    nil
  end
end